1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use {bytes::Bytes, http::Response, tsukuyomi::output::IntoResponse};
pub fn graphiql_source(url: impl AsRef<str> + 'static) -> impl IntoResponse + Clone {
GraphiQLSource {
source: juniper::http::graphiql::graphiql_source(url.as_ref()).into(),
}
}
#[derive(Debug, Clone)]
struct GraphiQLSource {
source: Bytes,
}
impl IntoResponse for GraphiQLSource {
#[inline]
fn into_response(self) -> tsukuyomi::output::Response {
Response::builder()
.header("content-type", "text/html; charset=utf-8")
.body(self.source.into())
.expect("should be a valid response")
}
}