servant-static-th 1.0.0.0 → 1.0.0.1
raw patch · 9 files changed
+35/−62 lines, 9 filesdep +hspecdep −Globdep −doctestdep ~basePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: hspec
Dependencies removed: Glob, doctest
Dependency ranges changed: base
API changes (from Hackage documentation)
- Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.CSS Data.ByteString.Internal.ByteString
- Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.EOT Data.ByteString.Internal.ByteString
- Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.GEXF Data.ByteString.Internal.ByteString
- Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.GIF Data.ByteString.Internal.ByteString
- Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.ICO Data.ByteString.Internal.ByteString
- Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.JPEG Data.ByteString.Internal.ByteString
- Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.JS Data.ByteString.Internal.ByteString
- Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.JSON Data.ByteString.Internal.ByteString
- Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.PNG Data.ByteString.Internal.ByteString
- Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.SVG Data.ByteString.Internal.ByteString
- Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.TTF Data.ByteString.Internal.ByteString
- Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.TXT Data.ByteString.Internal.ByteString
- Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.WASM Data.ByteString.Internal.ByteString
- Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.WOFF Data.ByteString.Internal.ByteString
- Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.WOFF2 Data.ByteString.Internal.ByteString
- Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.XML Data.ByteString.Internal.ByteString
+ Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.CSS Data.ByteString.Internal.Type.ByteString
+ Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.EOT Data.ByteString.Internal.Type.ByteString
+ Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.GEXF Data.ByteString.Internal.Type.ByteString
+ Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.GIF Data.ByteString.Internal.Type.ByteString
+ Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.ICO Data.ByteString.Internal.Type.ByteString
+ Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.JPEG Data.ByteString.Internal.Type.ByteString
+ Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.JS Data.ByteString.Internal.Type.ByteString
+ Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.JSON Data.ByteString.Internal.Type.ByteString
+ Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.PNG Data.ByteString.Internal.Type.ByteString
+ Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.SVG Data.ByteString.Internal.Type.ByteString
+ Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.TTF Data.ByteString.Internal.Type.ByteString
+ Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.TXT Data.ByteString.Internal.Type.ByteString
+ Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.WASM Data.ByteString.Internal.Type.ByteString
+ Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.WOFF Data.ByteString.Internal.Type.ByteString
+ Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.WOFF2 Data.ByteString.Internal.Type.ByteString
+ Servant.Static.TH.Internal.Mime: instance Servant.API.ContentTypes.MimeRender Servant.Static.TH.Internal.Mime.XML Data.ByteString.Internal.Type.ByteString
- Servant.Static.TH: data HTML
+ Servant.Static.TH: data () => HTML
Files
- CHANGELOG.md +6/−0
- README.md +0/−1
- servant-static-th.cabal +18/−11
- src/Servant/Static/TH/Internal/Api.hs +4/−3
- src/Servant/Static/TH/Internal/FileTree.hs +0/−1
- src/Servant/Static/TH/Internal/Mime.hs +2/−2
- src/Servant/Static/TH/Internal/Server.hs +3/−3
- test/DocTest.hs +0/−40
- test/Spec/ServerSpec.hs +2/−1
CHANGELOG.md view
@@ -1,5 +1,11 @@ # Changelog +## v1.0.0.1++- Few small fixes to make sure tests build with recent versions of GHC.+ [#22](https://github.com/cdepillabout/servant-static-th/pull/22).+ Thanks [@blackheaven](https://github.com/blackheaven)!+ ## v1.0.0.0 - Serve any files called `index.html` on the root `/` as well as the path
README.md view
@@ -3,7 +3,6 @@ ================== [](https://github.com/cdepillabout/servant-static-th/actions)-[](http://travis-ci.org/cdepillabout/servant-static-th) [](https://hackage.haskell.org/package/servant-static-th) [](http://stackage.org/lts/package/servant-static-th) [](http://stackage.org/nightly/package/servant-static-th)
servant-static-th.cabal view
@@ -1,5 +1,5 @@ name: servant-static-th-version: 1.0.0.0+version: 1.0.0.1 synopsis: Embed a directory of static files in your Servant server description: Please see <https://github.com/cdepillabout/servant-static-th#readme README.md>. homepage: https://github.com/cdepillabout/servant-static-th@@ -30,7 +30,7 @@ , Servant.Static.TH.Internal.Mime , Servant.Static.TH.Internal.Server , Servant.Static.TH.Internal.Util- build-depends: base >= 4.8 && < 5+ build-depends: base >= 4.15 && < 5 , blaze-html , bytestring , containers@@ -64,15 +64,21 @@ else buildable: False -test-suite servant-static-th-doctest- type: exitcode-stdio-1.0- main-is: DocTest.hs- hs-source-dirs: test- build-depends: base- , doctest- , Glob- default-language: Haskell2010- ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N+-- TODO: By default, recent versions of cabal don't run tests in+-- an environment that would allow doctests to work. This needs+-- to be updated to use a library like cabal-doctest, but there+-- are also various problems with that:+-- https://github.com/cdepillabout/pretty-simple/issues/82#issuecomment-2387289781+-- test-suite servant-static-th-doctest+-- type: exitcode-stdio-1.0+-- main-is: DocTest.hs+-- hs-source-dirs: test+-- build-depends: base+-- , doctest+-- , Glob+-- , servant-static-th+-- default-language: Haskell2010+-- ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N test-suite servant-static-th-test type: exitcode-stdio-1.0@@ -88,6 +94,7 @@ , bytestring , directory , filepath+ , hspec , hspec-wai , tasty , tasty-hspec
src/Servant/Static/TH/Internal/Api.hs view
@@ -5,7 +5,6 @@ module Servant.Static.TH.Internal.Api where -import Data.Foldable (foldl1) import Data.List.NonEmpty (NonEmpty) import Language.Haskell.TH (Dec, Q, Type, appT, litT, mkName,@@ -22,14 +21,16 @@ addDependentFile filePath MimeTypeInfo mimeT respT _ <- extensionToMimeTypeInfoEx filePath let fileName = takeFileName filePath- let fileNameLitT = litT $ strTyLit fileName+ let fileNameLitT :: Q Type+ fileNameLitT = litT $ strTyLit fileName case fileName of -- We special-case files called "index.html" and generate a type that serves on both -- the root, and under the path "index.html". "index.html" -> [t|Get '[$(mimeT)] $(respT) :<|> $(fileNameLitT) :> Get '[$(mimeT)] $(respT)|] _ -> [t|$(fileNameLitT) :> Get '[$(mimeT)] $(respT)|] fileTreeToApiType (FileTreeDir filePath fileTrees) =- let fileNameLitT = litT $ strTyLit $ takeFileName filePath+ let fileNameLitT :: Q Type+ fileNameLitT = litT $ strTyLit $ takeFileName filePath in [t|$(fileNameLitT) :> $(combineWithServantOrT nonEmptyApiTypesQ)|] where nonEmptyApiTypesQ :: NonEmpty (Q Type)
src/Servant/Static/TH/Internal/FileTree.hs view
@@ -18,7 +18,6 @@ import Data.List (sort) import Data.List.NonEmpty (NonEmpty((:|))) import Data.Maybe (catMaybes)-import Data.Monoid ((<>)) import System.Directory (doesDirectoryExist, doesFileExist, listDirectory) import System.FilePath ((</>))
src/Servant/Static/TH/Internal/Mime.hs view
@@ -27,7 +27,6 @@ import qualified Data.ByteString.Lazy as LByteString import Data.Map (Map) import qualified Data.Map as Map-import Data.Monoid ((<>)) import Data.Proxy (Proxy) import Data.Text (pack, unpack) import Data.Text.Encoding (decodeUtf8With, encodeUtf8)@@ -76,7 +75,8 @@ utf8ByteStringToExp :: ByteString -> Q Exp utf8ByteStringToExp byteString =- let stringExp = stringE . unpack $ decodeUtf8With lenientDecode byteString+ let stringExp :: Q Exp+ stringExp = stringE . unpack $ decodeUtf8With lenientDecode byteString packedExp = appE (varE 'pack) stringExp byteStringExp = appE (varE 'encodeUtf8) packedExp in appE (varE 'pure) byteStringExp
src/Servant/Static/TH/Internal/Server.hs view
@@ -4,12 +4,11 @@ module Servant.Static.TH.Internal.Server where -import Data.Foldable (foldl1)-import Data.List.NonEmpty (NonEmpty((:|)))+import Data.List.NonEmpty (NonEmpty) import Language.Haskell.TH (Dec, Exp, Q, appE, clause, conT, funD, mkName, normalB, runIO, sigD)-import Language.Haskell.TH.Syntax (addDependentFile)+import Language.Haskell.TH.Syntax (Type, addDependentFile) import Servant.API ((:<|>)((:<|>))) import Servant.Server (ServerT) import System.FilePath (takeFileName)@@ -126,6 +125,7 @@ -> Q [Dec] createServerDec apiName serverName templateDir = let funcName = mkName serverName+ sigTypeQ :: Q Type sigTypeQ = [t|forall m. Applicative m => ServerT $(conT (mkName apiName)) m|] signatureQ = sigD funcName sigTypeQ
− test/DocTest.hs
@@ -1,40 +0,0 @@--module Main (main) where--import Prelude--import Data.Monoid ((<>))-import System.FilePath.Glob (glob)-import Test.DocTest (doctest)--main :: IO ()-main = glob "src/**/*.hs" >>= doDocTest--doDocTest :: [String] -> IO ()-doDocTest options = doctest $ options <> ghcExtensions--ghcExtensions :: [String]-ghcExtensions =- [- -- "-XConstraintKinds"- -- , "-XDataKinds"- "-XDeriveDataTypeable"- , "-XDeriveGeneric"- -- , "-XEmptyDataDecls"- , "-XFlexibleContexts"- -- , "-XFlexibleInstances"- -- , "-XGADTs"- -- , "-XGeneralizedNewtypeDeriving"- -- , "-XInstanceSigs"- -- , "-XMultiParamTypeClasses"- -- , "-XNoImplicitPrelude"- , "-XOverloadedStrings"- -- , "-XPolyKinds"- -- , "-XRankNTypes"- -- , "-XRecordWildCards"- , "-XScopedTypeVariables"- -- , "-XStandaloneDeriving"- -- , "-XTupleSections"- -- , "-XTypeFamilies"- -- , "-XTypeOperators"- ]
test/Spec/ServerSpec.hs view
@@ -8,11 +8,12 @@ import Data.Proxy (Proxy(Proxy)) import Network.Wai (Application) import Servant.Server (serve)+import Test.Hspec (it) import Test.Hspec.Wai (ResponseMatcher(matchHeaders), (<:>), get, shouldRespondWith, with) import Test.Tasty (TestTree)-import Test.Tasty.Hspec (testSpec, it)+import Test.Tasty.Hspec (testSpec) import Servant.Static.TH (createApiAndServerDecs)