servant-streaming-docs (empty) → 0.2.0.0
raw patch · 5 files changed
+126/−0 lines, 5 filesdep +basedep +lensdep +servantsetup-changed
Dependencies added: base, lens, servant, servant-docs, servant-streaming
Files
- LICENSE +31/−0
- Setup.hs +2/−0
- servant-streaming-docs.cabal +40/−0
- src/Servant/Streaming/Docs.hs +16/−0
- src/Servant/Streaming/Docs/Internal.hs +37/−0
+ LICENSE view
@@ -0,0 +1,31 @@+Copyright Julian K. Arni (c) 2015++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Julian K. Arni nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.+
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ servant-streaming-docs.cabal view
@@ -0,0 +1,40 @@+-- This file has been generated from package.yaml by hpack version 0.20.0.+--+-- see: https://github.com/sol/hpack+--+-- hash: 74804cef0ef3a3470dcfa0dff03660fc820fa165a1c0bd780a0fdbad7f5eefcd++name: servant-streaming-docs+version: 0.2.0.0+synopsis: Client instances for the 'servant-docs' package.+description: This package defines instances that allow using the 'StreamBody' and 'StreamResponse' combinators in combination with 'servant-docs'+homepage: http://github.com/plow-technologies/servant-streaming#readme+bug-reports: https://github.com/plow-technologies/servant-streaming/issues+author: Julian K. Arni+maintainer: jkarni@gmail.com+copyright: (c) Julian K. Arni+license: BSD3+license-file: LICENSE+tested-with: GHC == 8.2.2+build-type: Simple+cabal-version: >= 1.10++source-repository head+ type: git+ location: https://github.com/plow-technologies/servant-streaming++library+ hs-source-dirs:+ src+ default-extensions: AutoDeriveTypeable ConstraintKinds DataKinds DefaultSignatures DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable FlexibleContexts FlexibleInstances FunctionalDependencies GADTs KindSignatures MultiParamTypeClasses OverloadedStrings RankNTypes RecordWildCards ScopedTypeVariables TypeFamilies TypeOperators+ ghc-options: -Wall+ build-depends:+ base >=4.7 && <4.11+ , lens+ , servant >=0.10 && <0.14+ , servant-docs >=0.10 && <0.14+ , servant-streaming >=0.2 && <0.3+ exposed-modules:+ Servant.Streaming.Docs+ Servant.Streaming.Docs.Internal+ default-language: Haskell2010
+ src/Servant/Streaming/Docs.hs view
@@ -0,0 +1,16 @@+-- | This module provides an instance for HasDocs for 'servant-streaming'+-- combinators, so that documentation can be generated for APIs that have+-- streaming request or response bodies.+--+-- As as convenience, it also re-exports the combinators themselves.+module Servant.Streaming.Docs+ ( StreamResponse+ , StreamBody+ , StreamResponseGet+ , StreamResponsePost+ , StreamResponsePut+ , StreamResponsePatch+ ) where++import Servant.Streaming+import Servant.Streaming.Docs.Internal ()
+ src/Servant/Streaming/Docs/Internal.hs view
@@ -0,0 +1,37 @@+{-# OPTIONS_GHC -fno-warn-orphans #-}++module Servant.Streaming.Docs.Internal where++import Control.Lens+import Data.Proxy (Proxy (Proxy))+import Servant.API hiding (Stream)+import Servant.API.ContentTypes (allMime, AllMime)+import GHC.TypeLits+import Servant.Docs+import Servant.Streaming+++instance (HasDocs subapi, AllMime contentTypes)+ => HasDocs (StreamBody contentTypes :> subapi) where+ docsFor _ (ep, action) opts+ = docsFor (Proxy :: Proxy subapi) (ep, action') opts+ where+ mimes = allMime (Proxy :: Proxy contentTypes)+ bodyFor x = ("Streaming Body", x, "--some streaming body--")++ action' = action & rqbody .~ (bodyFor <$> mimes)+ & rqtypes .~ mimes++instance (AllMime contentTypes, KnownNat status, ReflectMethod method)+ => HasDocs (StreamResponse method status contentTypes) where+ docsFor _ (ep, action) DocOptions{..} =+ single endpoint action'++ where endpoint = ep & method .~ method'+ action' = action & response.respBody .~ (bodyFor <$> mimes)+ & response.respTypes .~ mimes+ & response.respStatus .~ status+ mimes = allMime (Proxy :: Proxy contentTypes)+ bodyFor x = ("Streaming Body", x, "--some streaming body--")+ method' = reflectMethod (Proxy :: Proxy method)+ status = fromInteger $ natVal (Proxy :: Proxy status)