Stability | experimental |
---|---|
Maintainer | Alp Mestanogullari <alp@zalora.com> |
Safe Haskell | Safe-Inferred |
Some standard REST-y operations your Resource
s can
support out of the box.
Your type will have to implement a couple of class instances
to be usable with a backend. For the scotty backend, this means
having FromJSON
or ToJSON
instances and the appropriate
toResponse
implementations for the return types of your
database.
- module Servant.Resource
- module Servant.Context
- module Servant.Error
- data Add
- addWith :: Contains Add ops ~ False => (a -> c -> IO (r Add)) -> Resource c a i r e ops -> Resource c a i r e (Add : ops)
- data Delete
- deleteWith :: Contains Delete ops ~ False => (i -> c -> IO (r Delete)) -> Resource c a i r e ops -> Resource c a i r e (Delete : ops)
- data ListAll
- listAllWith :: Contains ListAll ops ~ False => (c -> IO [a]) -> Resource c a i r e ops -> Resource c a i r e (ListAll : ops)
- data Update
- updateWith :: Contains Update ops ~ False => (i -> a -> c -> IO (r Update)) -> Resource c a i r e ops -> Resource c a i r e (Update : ops)
- data View
- viewWith :: Contains View ops ~ False => (i -> c -> IO (Maybe a)) -> Resource c a i r e ops -> Resource c a i r e (View : ops)
Defining Resource
s
module Servant.Resource
module Servant.Context
module Servant.Error
Standard operations
addWith :: Contains Add ops ~ False => (a -> c -> IO (r Add)) -> Resource c a i r e ops -> Resource c a i r e (Add : ops)Source
deleteWith :: Contains Delete ops ~ False => (i -> c -> IO (r Delete)) -> Resource c a i r e ops -> Resource c a i r e (Delete : ops)Source
listAllWith :: Contains ListAll ops ~ False => (c -> IO [a]) -> Resource c a i r e ops -> Resource c a i r e (ListAll : ops)Source
updateWith :: Contains Update ops ~ False => (i -> a -> c -> IO (r Update)) -> Resource c a i r e ops -> Resource c a i r e (Update : ops)Source