New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consolidate verbs #276
Merged
Merged
Consolidate verbs #276
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
cda8bcf
Simplify verb combinators.
jkarni 190c75a
Add descriptive type synonyms for success responses.
jkarni c6071bf
Don't override status code on empty body.
jkarni 20ae7dc
Update CHANGELOG for Verbs change.
jkarni 9b2d7a7
Remove unnecesary () AllMimeRender instance.
jkarni 5909a6d
Fix rebase issues.
jkarni 208bcf5
Use Verb for servant-docs
jkarni bd77b4a
Verb for -mock, -js and -foreign.
jkarni 574e9c4
Export all Verb methods.
jkarni 783a849
Make NoContent still take an arg.
jkarni f1b6603
Review fixes
jkarni f9c6137
Refactor NoContent logic.
jkarni File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,7 +90,7 @@ type TestHeaders = '[Header "X-Example1" Int, Header "X-Example2" String] | |
|
||
type Api = | ||
"get" :> Get '[JSON] Person | ||
:<|> "deleteEmpty" :> Delete '[] () | ||
:<|> "deleteEmpty" :> DeleteNoContent '[JSON] NoContent | ||
:<|> "capture" :> Capture "name" String :> Get '[JSON,FormUrlEncoded] Person | ||
:<|> "body" :> ReqBody '[FormUrlEncoded,JSON] Person :> Post '[JSON] Person | ||
:<|> "param" :> QueryParam "name" String :> Get '[FormUrlEncoded,JSON] Person | ||
|
@@ -105,14 +105,14 @@ type Api = | |
ReqBody '[JSON] [(String, [Rational])] :> | ||
Get '[JSON] (String, Maybe Int, Bool, [(String, [Rational])]) | ||
:<|> "headers" :> Get '[JSON] (Headers TestHeaders Bool) | ||
:<|> "deleteContentType" :> Delete '[JSON] () | ||
:<|> "deleteContentType" :> DeleteNoContent '[JSON] NoContent | ||
api :: Proxy Api | ||
api = Proxy | ||
|
||
server :: Application | ||
server = serve api ( | ||
return alice | ||
:<|> return () | ||
:<|> return NoContent | ||
:<|> (\ name -> return $ Person name 0) | ||
:<|> return | ||
:<|> (\ name -> case name of | ||
|
@@ -125,7 +125,7 @@ server = serve api ( | |
:<|> (\ _request respond -> respond $ responseLBS badRequest400 [] "rawFailure") | ||
:<|> (\ a b c d -> return (a, b, c, d)) | ||
:<|> (return $ addHeader 1729 $ addHeader "eg2" True) | ||
:<|> return () | ||
:<|> return NoContent | ||
) | ||
|
||
|
||
|
@@ -157,11 +157,11 @@ sucessSpec = beforeAll (startWaiApp server) $ afterAll endWaiApp $ do | |
describe "Servant.API.Delete" $ do | ||
it "allows empty content type" $ \(_, baseUrl) -> do | ||
let getDeleteEmpty = getNth (Proxy :: Proxy 1) $ client api baseUrl manager | ||
(left show <$> runExceptT getDeleteEmpty) `shouldReturn` Right () | ||
(left show <$> runExceptT getDeleteEmpty) `shouldReturn` Right NoContent | ||
|
||
it "allows content type" $ \(_, baseUrl) -> do | ||
let getDeleteContentType = getLast $ client api baseUrl manager | ||
(left show <$> runExceptT getDeleteContentType) `shouldReturn` Right () | ||
(left show <$> runExceptT getDeleteContentType) `shouldReturn` Right NoContent | ||
|
||
it "Servant.API.Capture" $ \(_, baseUrl) -> do | ||
let getCapture = getNth (Proxy :: Proxy 2) $ client api baseUrl manager | ||
|
@@ -283,7 +283,7 @@ failSpec = beforeAll (startWaiApp failServer) $ afterAll endWaiApp $ do | |
_ -> fail $ "expected InvalidContentTypeHeader, but got " <> show res | ||
|
||
data WrappedApi where | ||
WrappedApi :: (HasServer api, Server api ~ ExceptT ServantErr IO a, | ||
WrappedApi :: (HasServer (api :: *), Server api ~ ExceptT ServantErr IO a, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this kind-annotation better or needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is needed (I needed to turn on |
||
HasClient api, Client api ~ ExceptT ServantError IO ()) => | ||
Proxy api -> WrappedApi | ||
|
||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before this change you couldn't return headers when returning
()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope - this fixes #239, which is that issue.