Skip to content

Commit

Permalink
Merge pull request #13 from haskell-servant/jkarni/content-types
Browse files Browse the repository at this point in the history
Jkarni/content types
  • Loading branch information
jkarni committed Feb 24, 2015
2 parents c1377e0 + b96a2d2 commit cae0b6e
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 118 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ master
------

* Added support for matrix parameters, see e.g. http://www.w3.org/DesignIssues/MatrixURIs.html
* Add support for serializing based on Accept header
(https://github.com/haskell-servant/servant-server/issues/9)
* Ignore trailing slashes
(https://github.com/haskell-servant/servant-server/issues/5)


0.2.3
-----
Expand Down
15 changes: 15 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{ pkgs ? import <nixpkgs> { config.allowUnfree = true; }
, src ? builtins.filterSource (path: type:
type != "unknown" &&
baseNameOf path != ".git" &&
baseNameOf path != "result" &&
baseNameOf path != "dist") ./.
, servant ? import ../servant {}
}:
pkgs.haskellPackages.buildLocalCabalWithArgs {
name = "servant-server";
inherit src;
args = {
inherit servant;
};
}
6 changes: 3 additions & 3 deletions example/greet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Servant
-- * Example

-- | A greet message data type
newtype Greet = Greet { msg :: Text }
newtype Greet = Greet { _msg :: Text }
deriving (Generic, Show)

instance FromJSON Greet
Expand All @@ -27,11 +27,11 @@ instance ToJSON Greet
-- API specification
type TestApi =
-- GET /hello/:name?capital={true, false} returns a Greet as JSON
"hello" :> Capture "name" Text :> QueryParam "capital" Bool :> Get Greet
"hello" :> Capture "name" Text :> QueryParam "capital" Bool :> Get '[JSON] Greet

-- POST /greet with a Greet as JSON in the request body,
-- returns a Greet as JSON
:<|> "greet" :> ReqBody Greet :> Post Greet
:<|> "greet" :> ReqBody '[JSON] Greet :> Post '[JSON] Greet

-- DELETE /greet/:greetid
:<|> "greet" :> Capture "greetid" Text :> Delete
Expand Down
34 changes: 17 additions & 17 deletions servant-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@ library
Servant.Server.Internal
Servant.Utils.StaticFiles
build-depends:
base >=4.7 && <5
, aeson
, attoparsec
, bytestring
, either >= 4.3
, http-types
, network-uri >= 2.6
, safe
, servant >= 0.2.2
, split
, string-conversions
, system-filepath
, text
, transformers
, wai
, wai-app-static >= 3.0.0.6
, warp
base >= 4.7 && < 5
, aeson >= 0.7 && < 0.9
, attoparsec >= 0.12 && < 0.13
, bytestring >= 0.10 && < 0.11
, either >= 4.3 && < 4.4
, http-types >= 0.8 && < 0.9
, network-uri >= 2.6 && < 2.7
, safe >= 0.3 && < 0.4
, servant >= 0.2 && < 0.4
, split >= 0.2 && < 0.3
, string-conversions >= 0.3 && < 0.4
, system-filepath >= 0.4 && < 0.5
, text >= 1.2 && < 1.3
, transformers >= 0.3 && < 0.5
, wai >= 3.0 && < 3.1
, wai-app-static >= 3.0 && < 3.1
, warp >= 3.0 && < 3.1
hs-source-dirs: src
default-language: Haskell2010
ghc-options: -Wall
Expand Down
2 changes: 0 additions & 2 deletions src/Servant.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module Servant (
-- | Using your types in request paths and query string parameters
module Servant.Common.Text,
-- | Utilities on top of the servant core
module Servant.QQ,
module Servant.Utils.Links,
module Servant.Utils.StaticFiles,
-- | Useful re-exports
Expand All @@ -19,6 +18,5 @@ import Data.Proxy
import Servant.API
import Servant.Common.Text
import Servant.Server
import Servant.QQ
import Servant.Utils.Links
import Servant.Utils.StaticFiles
5 changes: 3 additions & 2 deletions src/Servant/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module Servant.Server

, -- * Handlers for all standard combinators
HasServer(..)

) where

import Data.Proxy (Proxy)
Expand All @@ -23,8 +24,8 @@ import Servant.Server.Internal
--
-- Example:
--
-- > type MyApi = "books" :> Get [Book] -- GET /books
-- > :<|> "books" :> ReqBody Book :> Post Book -- POST /books
-- > type MyApi = "books" :> Get '[JSON] [Book] -- GET /books
-- > :<|> "books" :> ReqBody Book :> Post '[JSON] Book -- POST /books
-- >
-- > server :: Server MyApi
-- > server = listAllBooks :<|> postBook
Expand Down
Loading

0 comments on commit cae0b6e

Please sign in to comment.