Skip to content

Commit

Permalink
Adds couple of re-exports
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-k committed Nov 19, 2023
1 parent 1a18911 commit e34f632
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
4 changes: 1 addition & 3 deletions examples/mig-example-apps/RouteArgs/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ main = do
routeArgs :: Server IO
routeArgs =
withSwagger def $
withTrace $
Trace.withLogs $
"api"
/.
-- no args, constnat output
Expand All @@ -41,8 +41,6 @@ routeArgs =
, -- return error
"square-root" /. handleSquareRoot
]
where
withTrace = applyPlugin (Trace.logHttp Trace.V2)

-- | Simple getter
helloWorld :: Get (Resp Text)
Expand Down
8 changes: 8 additions & 0 deletions mig-extra/src/Mig/Extra/Plugin/Trace.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ module Mig.Extra.Plugin.Trace (
logHttpBy,
ppReq,
Verbosity (..),
withLogs,
withLogsBy,
) where

import Control.Monad
Expand Down Expand Up @@ -57,6 +59,12 @@ ifLevel current level vals
| level <= current = vals
| otherwise = []

withLogs :: (MonadIO m) => Server m -> Server m
withLogs = applyPlugin (logHttp V2)

withLogsBy :: (MonadIO m) => (Json.Value -> m ()) -> Server m -> Server m
withLogsBy toLogItem = applyPlugin (logHttpBy toLogItem V2)

-------------------------------------------------------------------------------------
-- through

Expand Down
2 changes: 2 additions & 0 deletions mig-extra/src/Mig/Extra/Server/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ import Control.Monad.IO.Class as X
import Control.Monad.Trans.Class as X
import Data.Aeson as X (FromJSON (..), ToJSON (..))
import Data.Default as X
import Data.Maybe as X
import Data.OpenApi as X (OpenApi, ToParamSchema (..), ToSchema (..))
import Data.String as X
import Data.Text as X (Text)
import GHC.Generics as X (Generic)
import Mig.Extra.Derive as X
Expand Down
2 changes: 2 additions & 0 deletions mig-server/src/Mig.hs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ import Control.Monad.IO.Class as X
import Control.Monad.Trans.Class as X
import Data.Aeson as X (FromJSON (..), ToJSON (..))
import Data.Default as X
import Data.Maybe as X
import Data.OpenApi as X (OpenApi, ToParamSchema (..), ToSchema (..))
import Data.String as X
import Data.Text as X (Text)
import GHC.Generics as X (Generic)
import Network.HTTP.Types.Header as X (RequestHeaders, ResponseHeaders)
Expand Down

0 comments on commit e34f632

Please sign in to comment.