The servant-options package

[ Tags: library, mit, web ] [ Propose Tags ]

Provide responses to OPTIONS requests for Servant applications.


[Skip to Readme]

Properties

Versions 0.1.0.0
Dependencies base (>=4.7 && <5), bytestring, http-types, servant-foreign, servant-server, text, wai [details]
License MIT
Copyright 2017 Lyndon Maydwell
Author Lyndon Maydwell
Maintainer maydwell@gmail.com
Category Web
Home page https://github.com/sordina/servant-options
Uploaded Tue Apr 4 04:05:39 UTC 2017 by LyndonMaydwell
Distributions NixOS:0.1.0.0
Downloads 165 total (45 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-04-04 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for servant-options-0.1.0.0

[back to package description]

Servant-Options

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.

Before:

After:

Usage:

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
  where
  policy = simpleCorsResourcePolicy
           { corsRequestHeaders = [ "content-type" ] }

See Also