{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Trasa.Method
(
Method
, encodeMethod
, decodeMethod
, get
, post
, head
, put
, delete
, trace
, connect
, options
, patch
) where
import Prelude hiding (head)
import Data.Hashable(Hashable(..))
import Data.String (IsString(..))
import qualified Data.Text as T
newtype Method = Method T.Text
deriving (Hashable,Eq,Ord)
instance Show Method where
show = show . encodeMethod
instance IsString Method where
fromString = decodeMethod . T.pack
encodeMethod :: Method -> T.Text
encodeMethod (Method txt) = txt
decodeMethod :: T.Text -> Method
decodeMethod = Method . T.toUpper
get :: Method
get = "GET"
post :: Method
post = "POST"
head :: Method
head = "HEAD"
put :: Method
put = "PUT"
delete :: Method
delete = "DELETE"
trace :: Method
trace = "TRACE"
connect :: Method
connect = "CONNECT"
options :: Method
options = "OPTIONS"
patch :: Method
patch = "PATCH"