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

Trailing slashes are appended to all endpoints #22

Closed
declension opened this Issue Feb 10, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@declension
Contributor

declension commented Feb 10, 2017

Note: total beginner, so apologies if I've missed something obvious.

I've been testing some external APIs using servant-quickcheck == 0.0.2.2 (and servant == 0.8.1) via lts-7.19, but getting errors that seemed strange... until I looked at the app logs and saw trailing slashes on every incoming request (the endpoints in that API didn't allow for this).

However I structure the API definition, Servant-* seems to be appending a trailing slash. I assumed it was me, but I made a simple test project with an API like:

type API = "path" :> Get '[JSON] Int

and watching the raw HTTP (in netcat) get:

GET /path/ HTTP/1.1
Host: localhost:8080
Accept-Encoding: gzip

Then when defining multi-part paths using multiple :> (as I understand is correct),

type API = "path" :> "sub" :> Get '[JSON] Int

I get

GET /pathsub/ HTTP/1.1
Host: localhost:8080
Accept-Encoding: gzip

Any ideas?

declension added a commit to declension/servant-quickcheck that referenced this issue Mar 11, 2017

Fix Path delimiting:
  * Add test API with multiple Path elements
  * Add basic test using this API, generating an endpoint to validate that query path delimiting is happening correctly (that fails on `master`)
  * Fix (re)creation of path to prepend `/` to each new path section, but only if it's non-empty (this fixes the trailing slashes, but still allows users to use a `:> "foo/" :>...` if their API demands trailing slashes)
  * Update / fix the existing test that now fails slightly differently (i.e. the trailing slash in `failplz/` is gone)

Fixes #22.

@jkarni jkarni closed this in #28 Mar 11, 2017

jkarni added a commit that referenced this issue Mar 11, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment