packages feed

webby 1.0.2 → 1.1.0

raw patch · 4 files changed

+44/−3 lines, 4 filesdep +mime-typesPVP ok

version bump matches the API change (PVP)

Dependencies added: mime-types

API changes (from Hackage documentation)

+ Webby: image :: ByteString -> MimeType -> WebbyM appEnv ()
+ Webby: raw :: ByteString -> WebbyM appEnv ()

Files

+ ChangeLog.md view
@@ -0,0 +1,9 @@+# Change log++## Unreleased - To be v1.1.0++* Add the `image` function to return mime-typed responses.++## Older releases++Please see commits in the repository.
src/Webby.hs view
@@ -41,6 +41,8 @@     json,     text,     stream,+    image,+    raw,      -- * Application     mkWebbyApp,
src/Webby/Server.hs view
@@ -6,6 +6,7 @@ import qualified Data.HashMap.Strict as H import qualified Data.List as L import qualified Data.Text as T+import Network.Mime import qualified UnliftIO.Concurrent as Conc import qualified UnliftIO.Exception as E import Web.HttpApiData@@ -126,11 +127,25 @@ finish :: WebbyM appEnv a finish = E.throwIO FinishThrown +-- | Send an image in the response body. Also+-- sets @Content-Type@ header to @mimeType+-- e.g. image/svg+xml+image :: ByteString -> MimeType -> WebbyM appEnv ()+image bs mimeType = do+  setHeader (hContentType, mimeType)+  raw bs+ -- | Send a binary stream in the response body. Also -- sets @Content-Type@ header to @application/octet-stream@ blob :: ByteString -> WebbyM appEnv () blob bs = do   setHeader (hContentType, "application/octet-stream")+  raw bs++-- | Send a binary stream in the response body. Doesn't+-- set @Content-Type@ header+raw :: ByteString -> WebbyM appEnv ()+raw bs = do   wVar <- asksWEnv weResp   Conc.modifyMVar_ wVar $     \wr -> return $ wr {wrRespData = Right $ Bu.fromByteString bs}
webby.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name:           webby-version:        1.0.2+version:        1.1.0 synopsis:       A super-simple web server framework description:    A super-simple, easy to use web server framework inspired by                 Scotty. The goals of the project are: (1) Be easy to use (2) Allow@@ -14,10 +14,16 @@ license:        Apache-2.0 license-file:   LICENSE build-type:     Simple+extra-doc-files:  ChangeLog.md+                  README.md extra-source-files:-    README.md-    LICENSE     examples/*.hs+tested-with:    GHC == 8.4.4+                GHC == 8.6.5+                GHC == 8.8.4+                GHC == 8.10.7+                GHC == 9.0.2+                GHC == 9.2.4  source-repository head   type: git@@ -44,7 +50,15 @@   if impl(ghc >= 8.8)     ghc-options:       -Wmissing-deriving-strategies                        -Werror=missing-deriving-strategies+  if impl(ghc >= 8.10)+    ghc-options:       -Wunused-packages+  if impl(ghc >= 9.0)+    ghc-options:       -Winvalid-haddock+  if impl(ghc >= 9.2)+    ghc-options:       -Wredundant-bang-patterns+                       -Woperator-whitespace +   default-language:    Haskell2010    default-extensions:@@ -80,6 +94,7 @@     , unliftio-core ==0.2.*     , unordered-containers >=0.2.9 && <0.3     , wai ==3.2.*+    , mime-types ==0.1.*    mixins:              base hiding (Prelude)