Last active
January 27, 2017 09:01
-
-
Save saurabhnanda/cab87791d38cca3bfe2cce66cead9080 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Saurabhs-MacBook-Pro:instrumentedopaleye saurabhnanda$ stack exec ghci | |
GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help | |
Prelude> :set -XPackageImports | |
Prelude> import "instrumentedopaleye" Web.Scotty.Trans | |
Prelude Web.Scotty.Trans> :i get | |
<interactive>:1:1: error: | |
Ambiguous interface for ‘Web.Scotty.Trans’: | |
it was found in multiple packages: | |
scotty-0.11.0 instrumentedopaleye-0.1.0.0 | |
Prelude Web.Scotty.Trans> import "instrumentedopaleye" Web.Scotty.Trans | |
<interactive>:1:1: error: | |
Ambiguous interface for ‘Web.Scotty.Trans’: | |
it was found in multiple packages: | |
scotty-0.11.0 instrumentedopaleye-0.1.0.0 | |
Prelude Web.Scotty.Trans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: instrumentedopaleye | |
version: 0.1.0.0 | |
synopsis: Initial project template from stack | |
description: Please see README.md | |
homepage: https://github.com/githubuser/dashboard#readme | |
license: BSD3 | |
author: Author name here | |
maintainer: example@example.com | |
copyright: 2016 Author name here | |
category: Web | |
build-type: Simple | |
extra-source-files: README.md | |
cabal-version: >=1.10 | |
library | |
hs-source-dirs: src | |
exposed-modules: InstrumentedOpaleye | |
, Instrumented | |
, InstrumentedOpaleye.Internal.PGTypes | |
, InstrumentedOpaleye.Internal.Column | |
, InstrumentedOpaleye.Internal.RunQuery | |
, InstrumentedOpaleye.Internal.HaskellDB.PrimQuery | |
, InstrumentedLucid | |
, Web.Scotty.Trans | |
, InstrumentedCore | |
build-depends: base >= 4.7 && < 5 | |
, opaleye | |
, profunctors | |
, product-profunctors | |
, postgresql-simple | |
, mtl | |
, time | |
, stm | |
, text | |
, uuid | |
, lucid | |
, scotty | |
, transformers | |
default-language: Haskell2010 | |
source-repository head | |
type: git | |
location: https://github.com/githubuser/dashboard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE PackageImports #-} | |
module Web.Scotty.Trans | |
( | |
module OS | |
, get | |
, post | |
, put | |
, delete | |
, patch | |
, options | |
, addroute | |
) | |
where | |
import qualified "scotty" Web.Scotty.Trans as OS hiding (get, post, put, delete, patch, options, addroute) | |
import qualified "scotty" Web.Scotty.Trans as S | |
import InstrumentedCore | |
import Control.Monad.Trans.Class(lift) | |
instrumentedAction original action = original action_ | |
where | |
action_ = do | |
st <- liftIO $ getCurrentTime | |
result <- action | |
en <- liftIO $ getCurrentTime | |
logInstrumentationData InstrumentationData{instrStart=st, instrEnd=en, instrPayload=Render} | |
return result | |
get route action = instrumentedAction (S.get route) action | |
post route action = instrumentedAction (S.post route) action | |
put route action = instrumentedAction (S.put route) action | |
delete route action = instrumentedAction (S.delete route) action | |
patch route action = instrumentedAction (S.patch route) action | |
options route action = instrumentedAction (S.options route) action | |
addroute method route action = instrumentedAction (S.addroute method route) action | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment