http-types-0.12.4: Generic HTTP types for Haskell (for both client and server code).

Safe Haskell | Safe-Inferred
Language | Haskell2010

Network.HTTP.Types.Method

Contents

- HTTP methods
  - Constants
  - Standard Methods

Description

Types and constants for HTTP methods.

The HTTP standard defines a set of standard methods, when to use them, and how to handle them. The standard set has been provided as a separate data type `StdMethod`, but since you can also use custom methods, the basic type `Method` is just a synonym for `ByteString`.

Synopsis

- type Method = ByteString
- methodGet :: Method
- methodPost :: Method
- methodHead :: Method
- methodPut :: Method
- methodDelete :: Method
- methodTrace :: Method
- methodConnect :: Method
- methodOptions :: Method
- methodPatch :: Method
- data StdMethod
  - = GET
  - | POST
  - | HEAD
  - | PUT
  - | DELETE
  - | TRACE
  - | CONNECT
  - | OPTIONS
  - | PATCH
- parseMethod :: Method -> Either ByteString StdMethod
- renderMethod :: Either ByteString StdMethod -> Method
- renderStdMethod :: StdMethod -> Method

# HTTP methods

type Method = ByteString #

HTTP method (flat `ByteString` type).

## Constants

methodGet :: Method #

HTTP GET Method

methodPost :: Method #

HTTP POST Method

methodHead :: Method #

HTTP HEAD Method

methodPut :: Method #

HTTP PUT Method

methodDelete :: Method #

HTTP DELETE Method

methodTrace :: Method #

HTTP TRACE Method

methodConnect :: Method #

HTTP CONNECT Method

methodOptions :: Method #

HTTP OPTIONS Method

methodPatch :: Method #

HTTP PATCH Method

Since: 0.8.0

## Standard Methods

One data type that holds all standard HTTP methods.

data StdMethod #

HTTP standard method (as defined by RFC 2616, and PATCH which is defined by RFC 5789).

Since: 0.2.0

Constructors

GET |
POST |
HEAD |
PUT |
DELETE |
TRACE |
CONNECT |
OPTIONS |
PATCH | Since: 0.8.0

#### Instances

Instances details

Data StdMethod # | Since: 0.12.4
Instance details Defined in Network.HTTP.Types.Method Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> StdMethod -> c StdMethod # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c StdMethod # toConstr :: StdMethod -> Constr # dataTypeOf :: StdMethod -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c StdMethod) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c StdMethod) # gmapT :: (forall b. Data b => b -> b) -> StdMethod -> StdMethod # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> StdMethod -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> StdMethod -> r # gmapQ :: (forall d. Data d => d -> u) -> StdMethod -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> StdMethod -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> StdMethod -> m StdMethod # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> StdMethod -> m StdMethod # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> StdMethod -> m StdMethod #
Bounded StdMethod # |
Instance details Defined in Network.HTTP.Types.Method Methods minBound :: StdMethod # maxBound :: StdMethod #
Enum StdMethod # |
Instance details Defined in Network.HTTP.Types.Method Methods succ :: StdMethod -> StdMethod # pred :: StdMethod -> StdMethod # toEnum :: Int -> StdMethod # fromEnum :: StdMethod -> Int # enumFrom :: StdMethod -> [StdMethod] # enumFromThen :: StdMethod -> StdMethod -> [StdMethod] # enumFromTo :: StdMethod -> StdMethod -> [StdMethod] # enumFromThenTo :: StdMethod -> StdMethod -> StdMethod -> [StdMethod] #
Generic StdMethod # |
Instance details Defined in Network.HTTP.Types.Method Associated Types
type Rep StdMethod | Since: http-types-0.12.4
Instance details Defined in Network.HTTP.Types.Method type Rep StdMethod = D1 ('MetaData "StdMethod" "Network.HTTP.Types.Method" "http-types-0.12.4-HhEPaOzd8crnbrvqiOppv" 'False) (((C1 ('MetaCons "GET" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "POST" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "HEAD" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PUT" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "DELETE" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TRACE" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "CONNECT" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OPTIONS" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PATCH" 'PrefixI 'False) (U1 :: Type -> Type)))))
Methods from :: StdMethod -> Rep StdMethod x # to :: Rep StdMethod x -> StdMethod #
Ix StdMethod # |
Instance details Defined in Network.HTTP.Types.Method Methods range :: (StdMethod, StdMethod) -> [StdMethod] # index :: (StdMethod, StdMethod) -> StdMethod -> Int # unsafeIndex :: (StdMethod, StdMethod) -> StdMethod -> Int # inRange :: (StdMethod, StdMethod) -> StdMethod -> Bool # rangeSize :: (StdMethod, StdMethod) -> Int # unsafeRangeSize :: (StdMethod, StdMethod) -> Int #
Read StdMethod # |
Instance details Defined in Network.HTTP.Types.Method Methods readsPrec :: Int -> ReadS StdMethod # readList :: ReadS [StdMethod] # readPrec :: ReadPrec StdMethod # readListPrec :: ReadPrec [StdMethod] #
Show StdMethod # |
Instance details Defined in Network.HTTP.Types.Method Methods showsPrec :: Int -> StdMethod -> ShowS # show :: StdMethod -> String # showList :: [StdMethod] -> ShowS #
Eq StdMethod # |
Instance details Defined in Network.HTTP.Types.Method Methods (==) :: StdMethod -> StdMethod -> Bool # (/=) :: StdMethod -> StdMethod -> Bool #
Ord StdMethod # |
Instance details Defined in Network.HTTP.Types.Method Methods compare :: StdMethod -> StdMethod -> Ordering # (<) :: StdMethod -> StdMethod -> Bool # (<=) :: StdMethod -> StdMethod -> Bool # (>) :: StdMethod -> StdMethod -> Bool # (>=) :: StdMethod -> StdMethod -> Bool # max :: StdMethod -> StdMethod -> StdMethod # min :: StdMethod -> StdMethod -> StdMethod #
type Rep StdMethod # | Since: 0.12.4
Instance details Defined in Network.HTTP.Types.Method type Rep StdMethod = D1 ('MetaData "StdMethod" "Network.HTTP.Types.Method" "http-types-0.12.4-HhEPaOzd8crnbrvqiOppv" 'False) (((C1 ('MetaCons "GET" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "POST" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "HEAD" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PUT" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "DELETE" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TRACE" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "CONNECT" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OPTIONS" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PATCH" 'PrefixI 'False) (U1 :: Type -> Type)))))

parseMethod :: Method -> Either ByteString StdMethod #

Convert a method `ByteString` to a `StdMethod` if possible.

Since: 0.2.0

renderMethod :: Either ByteString StdMethod -> Method #

Convert an algebraic method to a `ByteString`.

    renderMethod (parseMethod bs) == bs

Since: 0.3.0

renderStdMethod :: StdMethod -> Method #

Convert a `StdMethod` to a `ByteString`.

Since: 0.2.0