servant-options: Provide responses to OPTIONS requests for Servant applications.

[ library, mit, web ] [ Propose Tags ]

Provide responses to OPTIONS requests for Servant applications.

[Skip to Readme]




Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS]
Dependencies base (>=4.7 && <5), bytestring, http-types, servant-foreign, servant-server, text, wai [details]
License MIT
Copyright 2017 Lyndon Maydwell
Author Lyndon Maydwell
Category Web
Home page
Uploaded by LyndonMaydwell at 2017-04-04T04:05:39Z
Distributions Fedora:, NixOS:
Reverse Dependencies 2 direct, 0 indirect [details]
Downloads 3110 total (24 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-04-04 [all 1 reports]

Readme for servant-options-

[back to package description]


This library provides a middleware that returns HTTP OPTIONS responses for valid application routes defined by your (Proxy :: Proxy api). It is especially useful when trying to write an API that can be used in a cross-origin capacity, as browsers will send "pre-flight" checks by requesting OPTIONS for routes that are about to be called.




module MyApp where

import App
import Servant
import Network.Wai.Middleware.Cors
import Network.Wai.Middleware.Servant.Options

app :: Application
app = logStdoutDev
    $ cors (const $ Just policy)
    $ provideOptions apiProxy
    $ serve apiProxy apiServer
  policy = simpleCorsResourcePolicy
           { corsRequestHeaders = [ "content-type" ] }

See Also