Commit graph

708 commits

Author SHA1 Message Date
Alp Mestanogullari
c162e10676 Merge pull request #115 from haskell-servant/jkarni/patch-safe-link
Add missing Patch case for safeLink
2015-06-05 12:44:03 +01:00
Julian K. Arni
8b0ade729e Add missing Patch case for safeLink 2015-06-05 12:18:01 +02:00
Alp Mestanogullari
664691e1ba Merge pull request #114 from haskell-servant/jkarni/bump-string-conversions
Bump string-conversions
2015-06-04 14:56:40 +01:00
Alp Mestanogullari
e208977700 Merge pull request #112 from haskell-servant/jkarni/content-type-performance-fix
Don't render header via String
2015-06-04 14:23:58 +01:00
Julian K. Arni
d5091a68e1 Bump string-conversions 2015-06-04 15:09:01 +02:00
Julian Arni
e8f7c69aca Merge pull request #89 from PierreR/master
Use MonadThrow instead of Either in the signature of parseBaseUrl
2015-06-04 14:32:54 +02:00
Julian K. Arni
fb26e134d5 Don't render header via String 2015-06-04 14:28:28 +02:00
Alp Mestanogullari
d654ccaf3d Merge pull request #111 from haskell-servant/improved-routing
Improved routing
2015-06-04 12:57:45 +01: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
Andres Loeh
e83397a1db Fix the auth combinator example.
This change adapt the auth combinator example to the new router code.
In general, the server interpretation of user-written combinators will
be affected by the new routing code.

The change here also introduces a change in functionality: previously,
wrong authentication triggered a "hard failure", whereas we now trigger
a "soft failure", which is recoverable. For the simple example, this
does not make a lot of difference.

In general, I think having a soft failure is the right option to take
here, although we want a more general story about the relative
priorities of different error codes.
2015-06-04 13:12:21 +02:00
Andres Loeh
404bfdd89c Add test cases for the priority of error codes.
Due to the delayed treatment of checks during the server interpretation,
we now have the ability to produce "better" error codes for certain
APIs. This change introduces test cases for some of these situations and
their new, desired results. These tests would mostly fail with the old
approach to routing.
2015-06-04 13:10:21 +02:00
Andres Loeh
f9b1e7fc50 Switch server interpretation to a datatype for efficiency.
Instead of directly interpreting a server as a `RoutingApplication`,
this change introduces the concept of a `Router`, which is a datatype
with several constructors.

In particular, the type of the `route` function changes from

    route :: Proxy layout -> Server layout -> RoutingApplication

to

    route :: Proxy layout -> IO (RouteResult (Server layout)) -> Router

Most important in practice is the case of the `StaticRouter` constructor
in `Router`. For choices between statically known paths, we can now use
a lookup table to dispatch requests rather than trying each request
individually.

This brings down routing complexity of a common case from
O(n) to O(log n).

Another important change is that the handler that is passed down by
`route` is no longer of type `Server layout`, but of type
`IO (RouteResult (Server layout))`. This means that API constructs
can "delay" checks and failure. For example, `ReqBody` does not have
to fetch the request body and feed it to the handler immediately; it
can instead record these actions in the handler that is passed down.
The code will only be executed at a leaf / endpoint of the API.

This is desired behaviour: We prefer to save work by doing all matching
on static path components first. Furthermore, we get better error codes
by doing so.
2015-06-04 13:07:53 +02:00
Julian Arni
2725e20a1a Merge pull request #110 from bgamari/master
Bump aeson bound
2015-06-03 15:32:18 +02:00
Ben Gamari
74a52df1a1 API.Capture: Fix haddocks 2015-06-03 07:13:49 -04:00
Ben Gamari
939a008b67 Bump aeson bound 2015-06-03 06:53:34 -04:00
Julian K. Arni
0b3291970f Bump to 0.4.1 2015-05-29 16:24:08 +02:00
Alp Mestanogullari
9f1cb63206 fix HTML content types in haddocks 2015-05-29 16:08:14 +02:00
Alp Mestanogullari
db8cf8bd8d Merge pull request #106 from haskell-servant/jkarni/bump-either
Bump 'either' upper-bound
2015-05-29 14:56:45 +01:00
Julian K. Arni
ce012da4ee Bump 'either' upper-bound 2015-05-29 14:37:10 +02:00
Alp Mestanogullari
d785b7ff0f Merge pull request #105 from haskell-servant/jkarni/fix-docs
Fix outdated docs
2015-05-29 10:56:06 +01:00
Pierre Radermecker
3bcbe80c37 Fix for GHC-7.8.x 2015-05-29 11:13:10 +02:00
Julian K. Arni
5de9daf528 Fix outdated docs 2015-05-29 10:59:24 +02:00
Julian Arni
69936280b0 Merge pull request #102 from haskell-servant/jkarni/bound-for-servant-examples
Add servant bounds for servant-examples.
2015-05-28 12:31:26 +02:00
Julian K. Arni
7976468a32 Add servant bounds for servant-examples. 2015-05-28 11:22:43 +02:00
Alp Mestanogullari
c6467e2e70 Merge pull request #100 from haskell-servant/jkarni/servant-changelog
Update servant changelog
2015-05-27 15:32:59 +01:00
Alp Mestanogullari
0c5ae32518 Merge pull request #99 from haskell-servant/jkarni/bump-attoparsec
Bump attoparsec
2015-05-27 15:32:39 +01:00
Pierre Radermecker
520519bca9 Remove deps on HttpException from http-client 2015-05-27 15:36:28 +02:00
Pierre Radermecker
15b54cf1d0 Add AutoDeriveTypeable for ghc < 7.10 2015-05-27 15:36:28 +02:00
Pierre Radermecker
076286c37b Add a Exception instance for ServantError 2015-05-27 15:36:28 +02:00
Pierre Radermecker
717b18df4e Use MonadThrow instead of Either in the signature of parseBaseUrl 2015-05-27 15:36:28 +02:00
Julian K. Arni
35e7e386a5 Update servant changelog 2015-05-27 15:33:25 +02:00
Julian K. Arni
28387b7804 Update changelog 2015-05-27 15:29:34 +02:00
Julian K. Arni
2bff26feca Bump attoparsec 2015-05-27 15:19:30 +02:00
Julian Arni
de813c3269 Merge pull request #95 from haskell-servant/tvh/safeLink-92
More strict matching for Capture (safeLink)
2015-05-27 13:27:06 +02:00
Timo von Holtz
0f4c73bffe Make safeLink safer (#92) 2015-05-27 11:29:08 +10:00
Julian Arni
0a6e2aaf61 Merge pull request #96 from haskell-servant/jkarni/missing-test-modules
Add missing servant-client test modules
2015-05-26 12:34:55 +02:00
Julian Arni
cfd0b0d827 Merge pull request #97 from haskell-servant/jkarni/bump-version-script
Add bump-versions script
2015-05-26 12:22:30 +02:00
Julian Arni
3e10ee8a69 Merge pull request #72 from codedmart/deleteFix
Allow zero content types on delete. fixes #69
2015-05-26 12:19:23 +02:00
Julian K. Arni
49289ecbb4 Add bump-versions script 2015-05-26 12:18:26 +02:00
Julian K. Arni
f7b2232818 Add missing servant-client test modules 2015-05-26 12:07:44 +02:00
Timo von Holtz
ed7d235b26 Don't export HttpException 2015-05-25 17:51:35 +10:00
Alp Mestanogullari
5c25c56d50 Merge pull request #84 from haskell-servant/wip-json-decode-eof
fix a bug in our `eitherDecodeLenient` function
2015-05-23 12:56:31 +01:00
Julian Arni
763928cd66 Merge pull request #82 from triplepointfive/drop-system-filepath
Add support for wai-app-static-3.1.0
2015-05-18 12:55:40 +02:00
Brandon Martin
b45ac07ece HasClient instance for Delete cts' () now does not care at all about content types provided 2015-05-17 07:51:49 -06:00
Alp Mestanogullari
09e525fc76 Merge pull request #85 from haskell-servant/wip-better-error-doctest-failure
servant, servant-server: handle corner case in doctests, add an helpful error message
2015-05-16 09:49:05 +01:00
Alp Mestanogullari
e59c03faa2 Merge pull request #74 from haskell-servant/wip-whitespace-comment
servant: clean up some white spaces, add link explaining why Or works.
2015-05-16 08:28:28 +01:00
Christian Marie
54131821a5 servant: allow whitespace before JSON 2015-05-16 12:58:53 +10:00
Christian Marie
ec55177796 servant, servant-server: handle corner case in doctests
They seem to encounter multiple sandboxes sometimes, we now provide a more
helpful error if that happens. Didn't look into why this happens.
2015-05-16 12:45:08 +10:00
Christian Marie
43d0620403 servant: allow whitespace after parsing JSON
This includes some de-duplication in the test suite.
2015-05-16 11:13:41 +10:00