Skip to content

Commit be4a397

Browse files
authored
Simplify the sandbox module even more (#58)
1 parent a080e13 commit be4a397

File tree

1 file changed

+2
-13
lines changed
  • apollo-execution-ktor/src/commonMain/kotlin/com/apollographql/execution/ktor

1 file changed

+2
-13
lines changed

apollo-execution-ktor/src/commonMain/kotlin/com/apollographql/execution/ktor/main.kt

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -137,23 +137,12 @@ fun Application.apolloSubscriptionModule(
137137

138138
fun Application.apolloSandboxModule(
139139
title: String = "API sandbox",
140-
graphqlPath: String = "/graphql",
141140
sandboxPath: String = "/",
141+
endpoint: (RoutingCall) -> String = { it.url { path("/graphql") } },
142142
) {
143143
routing {
144144
get(sandboxPath) {
145-
val initialEndpoint = call.url {
146-
/**
147-
* Trying to guess if the client connected through HTTPS
148-
*/
149-
val proto = call.request.header("x-forwarded-proto")
150-
when (proto) {
151-
"http" -> protocol = URLProtocol.HTTP
152-
"https" -> protocol = URLProtocol.HTTPS
153-
}
154-
path(graphqlPath)
155-
}
156-
call.respondText(sandboxHtml(title, initialEndpoint), ContentType.parse("text/html"))
145+
call.respondText(sandboxHtml(title, endpoint(call)), ContentType.parse("text/html"))
157146
}
158147
}
159148
}

0 commit comments

Comments
 (0)