Skip to content

Commit ff05f9c

Browse files
committed
Merge remote-tracking branch 'origin/aeson-1.2.1.0' into francesco
2 parents 1ebbbaa + 4ec02f2 commit ff05f9c

File tree

5 files changed

+29
-5
lines changed

5 files changed

+29
-5
lines changed

solga-router/solga-router.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ library
2222
wai,
2323
bytestring,
2424
containers,
25-
aeson >= 1.0.0.0,
25+
aeson >= 1.2.1.0,
2626
wai-extra,
2727
http-types,
2828
resourcet,

solga-router/src/Solga/Router.hs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ module Solga.Router
2121
-- * Error handling
2222
, SolgaError
2323
, badRequest
24+
, unauthorized
25+
, forbidden
2426
, notFound
27+
, internalServerError
2528
-- * Router implementation
2629
, FromSegment(..)
2730
, Router(..)
@@ -281,9 +284,30 @@ badRequest msg = SolgaError
281284
, errorMessage = msg
282285
}
283286

287+
-- | Create a @401 Unauthorized@ error with a given message.
288+
unauthorized :: Text.Text -> SolgaError
289+
unauthorized msg = SolgaError
290+
{ errorStatus = HTTP.unauthorized401
291+
, errorMessage = msg
292+
}
293+
294+
-- | Create a @403 Forbidden@ error with a given message.
295+
forbidden :: Text.Text -> SolgaError
296+
forbidden msg = SolgaError
297+
{ errorStatus = HTTP.forbidden403
298+
, errorMessage = msg
299+
}
300+
284301
-- | Create a @404 Not Found@ error with a given message.
285302
notFound :: Text.Text -> SolgaError
286303
notFound msg = SolgaError
287304
{ errorStatus = HTTP.notFound404
288305
, errorMessage = msg
289306
}
307+
308+
-- | Create a @500 Internal Server Error@ error with a given message.
309+
internalServerError :: Text.Text -> SolgaError
310+
internalServerError msg = SolgaError
311+
{ errorStatus = HTTP.internalServerError500
312+
, errorMessage = msg
313+
}

solga-router/test/Test.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ spec = with (return $ serve testAPI) $ do
9494
resp <- get path
9595
liftIO $ decode (simpleBody resp) `shouldBe` Just (String seg)
9696

97-
9897
instance Arbitrary Value where
9998
arbitrary = sized arbJSON
10099
where

solga/src/Solga.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ module Solga
55

66
import Solga.Core
77
import Solga.Router
8+

stack.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# For more information, see: https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md
22

33
# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)
4-
resolver: nightly-2017-07-31
4+
resolver: lts-9.0
55

66
# Local packages, usually specified by relative directory name
77
packages:
@@ -13,8 +13,8 @@ packages:
1313

1414
# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)
1515
extra-deps:
16-
- swagger2-2.1.4.1
17-
- http-media-0.7.1.1
16+
- safe-exceptions-0.1.1.0
17+
- aeson-1.2.1.0
1818

1919
# Override default flag values for local packages and extra-deps
2020
flags: {}

0 commit comments

Comments
 (0)