Commit Graph

38 Commits

Author SHA1 Message Date
Oleg Grenrus 22ec980f6e Update hlint.yaml and fix some hints in servant and servant-server 2018-01-26 17:38:57 +02:00
Philipp Balzarek 08786aadbe Check for parse errors in HasServer Header instance 2017-04-06 14:52:55 +02:00
Oleg Grenrus 58e931f48a Resolve todos 2017-01-19 11:26:50 +02:00
Philipp Balzarek 3a0cbdd0f6 throw 400 on query parameter parse failure 2017-01-19 11:09:30 +02:00
Oleg Grenrus d4fe0e582a Fix stylistic issues 2017-01-19 00:57:31 +02:00
Oleg Grenrus 2caabad61a Expose ResourceT, fix the test 2017-01-19 00:57:31 +02:00
Oleg Grenrus bc6ff20f4d Use resourcet for resource managment 2017-01-19 00:57:31 +02:00
Alp Mestanogullari bc13d5cd3e warning free 2017-01-17 23:10:29 +02:00
Alp Mestanogullari 92786feead add some basic tests for the cleanup machinery in Delayed 2017-01-17 22:29:37 +02:00
Alp Mestanogullari 5d1f03ba1a use an ioref to store clean up actions instead of a field in Delayed, allowing early clean up registration 2017-01-17 22:29:37 +02:00
Alp Mestanogullari 7fb11dae3c make cleanup in Delayed more resistant to exceptions 2017-01-17 22:29:37 +02:00
Alp Mestanogullari 6ab0296d62 fix a warning 2017-01-17 22:29:37 +02:00
Alp Mestanogullari 124c6de1eb add a field in Delayed that lets us specify a clean up action that can use the result of bodyD to perform some IO clean up operation 2017-01-17 22:29:36 +02:00
Oleg Grenrus 5168157757 Make Handler a newtype 2017-01-16 12:18:49 +02:00
Jonathan Lange c79a254b36 servant-server support for CaptureAll 2016-07-11 14:46:31 +01:00
Andres Loeh a551eb62e2 Do the accept check before the body check.
This is a reasonably simple attempt at fixing #460.
By moving the accept check to a place before the body check,
we can make it recoverable (the body check is irreversible,
so everything done after the body check has to fail fatally).

The advantage is that we can now specify routes offering
different content types modularly. Failure to match one
is not fatal, and will result in subsequent routes being
tried.

The disadvantage is that we hereby bump the error priority
of the 406 status code. If a request contains a bad accept
header and a bad body, we now get 406 rather than 400. This
deviates from the HTTP decision diagram we try to follow,
but seems like an acceptable compromise for now.
2016-04-15 10:54:22 +02:00
Andres Loeh b1a6d88845 Revise the Router type to allow proper sharing.
We've previously used functions in the Router type to provide
information for subrouters. But this accesses the Requests too
early, and breaks sharing of the router structure in general,
causing the Router or large parts of the Router to be recomputed
on every request.

We now do not use functions anymore, and properly compute all
static parts of the router first, and gain access to the request
only in Delayed.

This also turns the code used within Delayed into a proper monad
now called DelayedIO, making some of the code using it a bit
nicer.
2016-04-12 09:38:49 +02:00
Luke Cycon 21546991af Introduce a `Handler` alias for `ExceptT ServantErr IO`
Fixes #434
2016-04-11 22:27:29 -07:00
Andres Loeh 8c778825c7 Improvements and visualization of router structure.
* Improves how Routers are built, in particular via
the `choice` smart constructors. Static lookups are
now used more often.

* We now have test cases making sure that certain
routers have the same structure.

* The router structure can now be visualized for debugging
purposes as a tree. The new functions `layout` and
`layoutWithContext` do this.
2016-04-11 08:08:37 +02:00
Denis Redozubov a22a981190 update base-compat imports 2016-03-13 12:44:12 +03:00
Denis Redozubov c755f47806 use base-compat in servant-server 2016-03-13 12:42:41 +03:00
aaron levin 104ac29bf8 Add BasicAuth support to servant-server 2016-03-08 23:13:02 +01:00
aaron levin 84172c6135 Augment Delayed to handle authentication. 2016-03-08 23:08:17 +01:00
Julian K. Arni f137972e5d Add 'serveWithConfig'.
And keep the old signature for 'serve'
2016-02-18 16:36:24 +01:00
Julian Arni 761443fffe Merge pull request #357 from haskell-servant/jkarni/remove-memoReqBody
Remove memoReqBody.
2016-02-05 20:05:49 +01:00
Andres Loeh 927009408b Small whitespace fix. 2016-01-28 11:08:22 +01:00
Andres Loeh 2934bac40c Small whitespace fix. 2016-01-28 11:07:59 +01:00
Andres Loeh c532ecffd5 Small doc fix. 2016-01-28 11:07:36 +01:00
Julian K. Arni 1aeee3ef94 Remove memoReqBody. 2016-01-26 14:43:15 +01:00
Christian Marie 9c67267071 servant-server: fix comment typo 2016-01-19 11:06:38 +11:00
Julian K. Arni 9c12b7839b 7.8 routing fixes, -Wall, cleanup, changelog. 2015-10-26 16:56:46 +01:00
Andres Loeh 1398d1f5e1 More systematic approach to delayed checks.
This introduces a `Delayed` type in `RoutingApplication.hs` that
contains a handler together with delayed checks. There are several
blocks of delayed checks, so that we can ultimately execute them in the
order we desire.

The process is documented in more detail in `RoutingApplication.hs`.
2015-10-26 16:56:25 +01:00
Julian K. Arni ccadba81ec Cleanup errorspec description of routing, changelog.
Review fixes
2015-10-26 16:55:13 +01:00
Julian K. Arni a3b5652ab9 Refactor RouteResult.
Fix rerouting tests
        Fix 405 > 404 issue with Capture.
        Remove ServantErrWithPriority and Monoid instance
        More tests
        Update auth-combinator for routing changes
2015-10-26 16:54:49 +01:00
Index Int f2f7b061d2 Drop `EitherT` in favor of `ExceptT` 2015-09-12 15:11:24 +03:00
Julian K. Arni 6eb7add53a stylish haskell changes
And import fix.
2015-08-18 00:07:12 +02:00
Andres Loeh 31b12d4bf4 Refactoring: abstracting common parts of method handlers.
This change makes an attempt of abstracting out some of the common
functionality found in the handlers for the different request methods.
There's still a bit of code duplication between the cases for headers
and no headers and empty responses. But it's a significant relative
improvement already.
2015-06-04 13:14:51 +02:00
Andres Loeh eb86a82105 Refactoring: one module per concept.
The main `Server.Internal` module was getting a bit large for my taste.
It now contains just the instances. All the administrative utilities
are in their own dedicated modules.
2015-06-04 13:14:31 +02:00