From d460c73bd0af88dcbc6cd02c611b20ddfe237b42 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Thu, 7 Nov 2019 10:35:18 +0100 Subject: [PATCH] shave off unused modules --- breve.cabal | 8 ++++---- src/Application.hs | 20 ++++++++++---------- src/Main.hs | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/breve.cabal b/breve.cabal index 5058627..5c18b4a 100644 --- a/breve.cabal +++ b/breve.cabal @@ -33,11 +33,11 @@ executable breve other-extensions: RecordWildCards, DeriveGeneric, DataKinds, KindSignatures, TypeOperators build-depends: base >=4.8 && <5.0, - warp, warp-tls, tls, blaze-html, blaze-markup, - servant-server, servant, servant-blaze, + warp, warp-tls, tls, blaze-html, + servant, servant-server, servant-blaze, wai, wai-extra, streaming-commons, http-api-data, - transformers, mtl, - text, aeson, bytestring, binary, + + mtl, text, aeson, bytestring, binary, hashtables, cryptohash, random, configurator, directory ghc-options: -threaded -O2 diff --git a/src/Application.hs b/src/Application.hs index 10ceb37..da3e885 100644 --- a/src/Application.hs +++ b/src/Application.hs @@ -15,7 +15,6 @@ import Breve.UrlTable import Views -- Misc -import Data.Monoid import Control.Monad.IO.Class (liftIO) import qualified Data.Text.IO as T @@ -25,19 +24,19 @@ import Data.Aeson (ToJSON) import GHC.Generics (Generic) -- HTML replies -import Text.Blaze.Html5 (Html) -import Text.Blaze.Renderer.Utf8 (renderMarkup) +import Text.Blaze.Html5 (Html) +import Text.Blaze.Html.Renderer.Utf8 (renderHtml) -- API definition import Servant import Servant.HTML.Blaze (HTML) import Web.FormUrlEncoded (FromForm(..), parseUnique) -import GHC.TypeNats (Nat) -- * Types -- | API successful reply +-- -- This is the reply returned by the JSON API -- handler when the url has been shortned -- successfully. @@ -49,7 +48,7 @@ data ApiReply = ApiReply instance ToJSON ApiReply --- | This type is just a wrapped around a 'Text' +-- | This type is just a wrapper around a 'Text' -- value. It's used to create a 'FromForm' instance -- for a 'Url'. newtype UrlForm = UrlForm Text @@ -92,15 +91,16 @@ type App = -- +----------+------+----------------------+ -- | path | type | description | -- +==========+======+======================+ --- | / | POST | upload a new url | +-- | /api | POST | upload a new url | -- +----------+------+----------------------+ type API = "api" :> ReqBody '[FormUrlEncoded] UrlForm :> Post '[JSON] ApiReply -- | Breve application --- --- Breve takes as parameters the bind url and the urls table -breve :: FilePath -> Url -> UrlTable -> Application +breve :: FilePath -- ^ static assets path + -> Url -- ^ bind url + -> UrlTable -- ^ url hashtable + -> Application breve static url table = serve (Proxy :: Proxy Breve) (breveServer static url table) -- | Empty application @@ -135,7 +135,7 @@ resolver table name = do url <- liftIO (extract table name) case url of Nothing -> - throwError $ err404 { errBody = renderMarkup (message "404: not found") } + throwError $ err404 { errBody = renderHtml (message "404: not found") } Just url -> do logStr ("Resolved " <> name <> " -> " <> url) pure (addHeader url NoContent) diff --git a/src/Main.hs b/src/Main.hs index a9c9739..8ed2db1 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -7,7 +7,7 @@ run the Breve webserver. module Main where -- Breve modules -import Application +import Application (breve, emptyApp) import Breve.Settings import Breve.UrlTable import Paths_breve (getDataFileName)