mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-12 04:08:29 +01:00
Merge pull request #267 from fpco/healthz-as-middleware
healthz is a middleware
This commit is contained in:
commit
f909a18e83
@ -29,7 +29,7 @@ import Data.WebsiteContent
|
||||
import Database.Persist.Postgresql (PostgresConf(..))
|
||||
import Import hiding (catch)
|
||||
import Language.Haskell.TH.Syntax (qLocation)
|
||||
import Network.Wai (Middleware, rawPathInfo)
|
||||
import Network.Wai (Middleware, rawPathInfo, pathInfo, responseBuilder)
|
||||
import Network.Wai.Handler.Warp (Settings, defaultSettings,
|
||||
defaultShouldDisplayException, getPort,
|
||||
runSettings, setHost, setOnException, setPort)
|
||||
@ -91,6 +91,7 @@ makeApplication foundation = do
|
||||
appPlain <- toWaiAppPlain foundation
|
||||
|
||||
let middleware = id -- prometheus def
|
||||
. healthz
|
||||
#if !DEVELOPMENT
|
||||
. forceSSL' (appSettings foundation)
|
||||
#endif
|
||||
@ -101,6 +102,13 @@ makeApplication foundation = do
|
||||
|
||||
return (middleware appPlain)
|
||||
|
||||
-- | Bypass any overhead from Yesod
|
||||
healthz :: Middleware
|
||||
healthz app req send =
|
||||
case pathInfo req of
|
||||
["healthz"] -> send $ responseBuilder status200 [("content-type", "text/plain; charset=utf-8")] "OK"
|
||||
_ -> app req send
|
||||
|
||||
forceSSL' :: AppSettings -> Middleware
|
||||
forceSSL' settings app
|
||||
| appForceSsl settings = \req send ->
|
||||
|
||||
@ -17,7 +17,7 @@ import Stackage.Database
|
||||
import Yesod.GitRepo (grContent)
|
||||
|
||||
getHealthzR :: Handler String
|
||||
getHealthzR = return "OK"
|
||||
getHealthzR = return "This should never be used, we should use the middleware instead"
|
||||
|
||||
-- This is a handler function for the G request method on the HomeR
|
||||
-- resource pattern. All of your resource patterns are defined in
|
||||
|
||||
Loading…
Reference in New Issue
Block a user