linnet-0.1.0.0: Lightweight library for building HTTP API

Safe HaskellNone
LanguageHaskell2010

Linnet.Endpoints

Synopsis

Documentation

cookie :: forall a m. (DecodeEntity a, MonadThrow m) => ByteString -> Endpoint m a Source #

Endpoint that tries to decode cookie name from a request. Always matches, but may throw an exception in case:

  • Cookie is not presented in the request
  • There was a cookie decoding error

cookieMaybe :: forall a m. (DecodeEntity a, MonadThrow m) => ByteString -> Endpoint m (Maybe a) Source #

Endpoint that tries to decode cookie name from a request. Always matches, but may throw an exception in case:

  • There was a cookie decoding error

header :: forall a m. (DecodeEntity a, MonadThrow m) => ByteString -> Endpoint m a Source #

Endpoint that tries to decode header name from a request. Always matches, but may throw an exception in case:

  • Headers is not presented in the request
  • There was a header decoding error

headerMaybe :: forall a m. (DecodeEntity a, MonadThrow m) => ByteString -> Endpoint m (Maybe a) Source #

Endpoint that tries to decode header name from a request. Always matches, but may throw an exception in case:

  • There was a header decoding error

get :: Endpoint m a -> Endpoint m a Source #

Turn endpoint into one that matches only for GET requests

post :: Endpoint m a -> Endpoint m a Source #

Turn endpoint into one that matches only for POST requests

put :: Endpoint m a -> Endpoint m a Source #

Turn endpoint into one that matches only for PUT requests

patch :: Endpoint m a -> Endpoint m a Source #

Turn endpoint into one that matches only for PATCH requests

delete :: Endpoint m a -> Endpoint m a Source #

Turn endpoint into one that matches only for DELETE requests

head' :: Endpoint m a -> Endpoint m a Source #

Turn endpoint into one that matches only for HEAD requests

trace' :: Endpoint m a -> Endpoint m a Source #

Turn endpoint into one that matches only for TRACE requests

connect :: Endpoint m a -> Endpoint m a Source #

Turn endpoint into one that matches only for CONNECT requests

options :: Endpoint m a -> Endpoint m a Source #

Turn endpoint into one that matches only for OPTIONS requests

param :: forall a m. (DecodeEntity a, MonadThrow m) => ByteString -> Endpoint m a Source #

Endpoint that tries to decode parameter name from the request query string. Always matches, but may throw an exception in case:

  • Parameter is not presented in request query
  • There was a parameter decoding error

paramMaybe :: forall a m. (DecodeEntity a, MonadThrow m) => ByteString -> Endpoint m (Maybe a) Source #

Endpoint that tries to decode parameter name from the request query string. Always matches, but may throw an exception in case:

  • There was a parameter decoding error

params :: forall a m. (DecodeEntity a, MonadThrow m) => ByteString -> Endpoint m [a] Source #

Endpoint that tries to decode all parameters name from the request query string. Always matches, but may throw an exception in case:

  • There was a parameter decoding error of at least one parameter value

paramsNel :: forall a m. (DecodeEntity a, MonadThrow m) => ByteString -> Endpoint m (NonEmpty a) Source #

Endpoint that tries to decode all parameters name from the request query string. Always matches, but may throw an exception in case:

  • There was a parameter decoding error of at least one parameter value
  • All parameters are empty or missing in request query

path :: forall a m. (DecodePath a, Applicative m, Typeable a) => Endpoint m a Source #

Endpoint that tries to decode head of the current path reminder into specific type. It consumes head of the reminder.

  • If path is empty, Endpoint is not matched
  • If decoding has failed, Endpoint is not matched

pathConst :: Applicative m => Text -> Endpoint m (HList '[]) Source #

Endpoint that matches only if the head of current path reminder is equal to some given constant value. It consumes head of the reminder.

  • If value matches the provided constant, saves the tail of the path as a reminder
  • Otherwise, resulting endpoint is not matched

p' :: Applicative m => Text -> Endpoint m (HList '[]) Source #

Short alias for pathConst

pathEmpty :: Applicative m => Endpoint m (HList '[]) Source #

Endpoint that matches only against empty path reminder

paths :: forall a m. (DecodePath a, Applicative m, Typeable a) => Endpoint m [a] Source #

Endpoint that consumes the rest of the path reminder and decode it using provided DecodePath for some type a

pathAny :: Applicative m => Endpoint m (HList '[]) Source #

Endpoint that matches any path and discards reminder

body :: forall ct a m. (Decode ct a, MonadIO m, MonadThrow m) => Endpoint m a Source #

Endpoint that tries to decode body of request into some type a using corresponding Decode instance. Matches if body isn't chunked. May throw an exception in case:

  • Body is empty
  • There was a body decoding error

bodyMaybe :: forall ct a m. (Decode ct a, MonadIO m, MonadThrow m) => Endpoint m (Maybe a) Source #

Endpoint that tries to decode body of request into some type a using corresponding Decode instance. Matches if body isn't chunked. May throw an exception in case:

  • There was a body decoding error

textBody :: (Decode TextPlain a, MonadIO m, MonadThrow m) => Endpoint m a Source #

Alias for body @TextPlain

textBodyMaybe :: (Decode TextPlain a, MonadIO m, MonadThrow m) => Endpoint m (Maybe a) Source #

Alias for bodyMaybe @TextPlain

jsonBody :: (Decode ApplicationJson a, MonadIO m, MonadThrow m) => Endpoint m a Source #

Alias for body @ApplicationJson

jsonBodyMaybe :: (Decode ApplicationJson a, MonadIO m, MonadThrow m) => Endpoint m (Maybe a) Source #

Alias for bodyMaybe @ApplicationJson