summaryrefslogtreecommitdiffhomepage
path: root/HTTP
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-09-27 12:36:37 -0400
committerJoey Hess <joeyh@joeyh.name>2016-09-27 12:36:37 -0400
commitd154002e063c1c3af5aba13cf05a11df8b8f9897 (patch)
tree86ebc67990feb68fe50862c58c34e47b8ff30779 /HTTP
parent90ff9f8872b0b4157a7e755e00eedf88907c98f1 (diff)
downloadkeysafe-d154002e063c1c3af5aba13cf05a11df8b8f9897.tar.gz
Server: --motd can be used to provide a Message Of The Day.
This commit was sponsored by Anthony DeRobertis on Patreon.
Diffstat (limited to 'HTTP')
-rw-r--r--HTTP/Server.hs9
1 files changed, 6 insertions, 3 deletions
diff --git a/HTTP/Server.hs b/HTTP/Server.hs
index c667601..f2ecfa8 100644
--- a/HTTP/Server.hs
+++ b/HTTP/Server.hs
@@ -24,6 +24,7 @@ import Control.Monad.IO.Class
import Control.Concurrent
import Control.Concurrent.Thread.Delay
import Control.Concurrent.STM
+import Data.Maybe
import Data.String
import qualified Data.ByteString as B
@@ -32,6 +33,7 @@ data ServerState = ServerState
, storage :: Storage
, rateLimiter :: RateLimiter
, logger :: Logger
+ , serverConfig :: ServerConfig
}
newServerState :: Maybe LocalStorageDirectory -> ServerConfig -> IO ServerState
@@ -42,6 +44,7 @@ newServerState d cfg = do
<*> pure (serverStorage d)
<*> newRateLimiter cfg d l
<*> pure l
+ <*> pure cfg
runServer :: Maybe LocalStorageDirectory -> ServerConfig -> IO ()
runServer d cfg = do
@@ -62,13 +65,13 @@ userAPI :: Proxy HttpAPI
userAPI = Proxy
server :: ServerState -> Server HttpAPI
-server st = motd
+server st = motd st
:<|> getObject st
:<|> putObject st
:<|> countObjects st
-motd :: Handler Motd
-motd = return $ Motd "Hello World!"
+motd :: ServerState -> Handler Motd
+motd = return . Motd . fromMaybe "Hello World!" . serverMotd . serverConfig
getObject :: ServerState -> StorableObjectIdent -> Maybe ProofOfWork -> Handler (POWGuarded StorableObject)
getObject st i pow = rateLimit (rateLimiter st) (logger st) pow i $ do