Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix path matching in graphql-cohttp #149

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions graphql-cohttp/src/graphql_cohttp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ module Make
let req_path = Cohttp.Request.uri req |> Uri.path in
let path_parts = Astring.String.cuts ~sep:"/" req_path in
match req.meth, path_parts with
| `GET, ["graphql"] ->
| `GET, [""; "graphql"] ->
if Cohttp.Header.get req.Cohttp.Request.headers "Connection" = Some "Upgrade" && Cohttp.Header.get req.headers "Upgrade" = Some "websocket" then
let handle_conn = Websocket_transport.handle (execute_query (make_context req) schema) in
Io.return (Ws.upgrade_connection req handle_conn)
else
static_file_response "index.html"
| `GET, ["graphql"; path] -> static_file_response path
| `POST, ["graphql"] -> execute_request schema (make_context req) req body
| `GET, [""; "graphql"; path] -> static_file_response path
| `POST, [""; "graphql"] -> execute_request schema (make_context req) req body
| _ -> respond_string ~status:`Not_found ~body:"" ()
end