{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
module Boots.Factory.Random(
buildRandom
) where
import Boots
import Boots.Factory.Web
buildRandom
:: forall context env n
. (HasWeb context env, MonadMask n, MonadIO n)
=> Proxy context -> Proxy env -> Factory n (WebEnv env context) ()
buildRandom _ _ = tryBuildByKey True "web.random.enabled" $
registerMiddleware $ \app env req resH -> do
seed <- unRD (view askRandom env) splitSMGen
makeRD0 seed $ \rd -> app (over askRandom (const rd) env) req resH