{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
module Boots.Web(
bootWeb
, module Boots.Factory.Web
, module Boots.Metrics
, module Boots.Factory.Endpoint
, module Boots.Factory.Trace
, module Boots.Factory.Error
, module Boots.Factory.Random
) where
import Boots.Factory.Web
import Boots.Metrics
import Boots.Factory.Endpoint
import Boots.Factory.Error
import Boots.Factory.Random
import Boots.Factory.Trace
import Boots
import Data.Version (Version)
bootWeb
:: forall api env context
. ( HasServer api context
, HasSwagger api
, HasWeb context env)
=> String
-> Version
-> (AppEnv -> env)
-> (env -> Context context)
-> (Proxy context -> Proxy env -> Factory IO (WebEnv env context) ())
-> Proxy api
-> ServerT api (App env)
-> IO ()
bootWeb appName ver fenv fcxt buildCustom api server = boot $ do
app <- buildApp appName ver
within app $ do
conf <- require "application"
ec <- require "endpoints"
store <- liftIO newStore
logInfo $ "Start Service [" <> toLogStr (name app) <> "] ..."
let
c = newWebEnv
(fenv app)
fcxt
conf
ec
store :: WebEnv env context
pe = Proxy @env
pc = Proxy @context
within c $ do
tryServeWithSwagger True pc api server
buildError pc pe
buildCustom pc pe
buildWebLogger pc pe
buildTrace pc pe
buildRandom pc pe
buildEndpoints pc pe
buildWeb pc pe