module Network.HTTP.Kinder.Header.Definitions (
SomeHeaderName (SomeHeaderName)
, headerName
, parseHeaderName
, HeaderName (..)
, Sing (
SCustomHeader
, SAccept
, SAcceptCharset
, SAcceptEncoding
, SAcceptLanguage
, SAcceptPatch
, SAcceptRanges
, SAccessControlAllowCredentials
, SAccessControlAllowHeaders
, SAccessControlAllowMethods
, SAccessControlAllowOrigin
, SAccessControlExposeHeaders
, SAccessControlMaxAge
, SAccessControlRequestHeaders
, SAccessControlRequestMethod
, SAge
, SAllow
, SAuthorization
, SCacheControl
, SConnection
, SContentDisposition
, SContentEncoding
, SContentLanguage
, SContentLength
, SContentLocation
, SContentRange
, SContentSecurityPolicy
, SContentType
, SCookie
, SDate
, SETag
, SExpect
, SExpires
, SFrom
, SHost
, SIfMatch
, SIfModifiedSince
, SIfNoneMatch
, SIfRange
, SIfUnmodifiedSince
, SLastModified
, SLink
, SLocation
, SMaxForwards
, SOrigin
, SPragma
, SProxyAuthenticate
, SProxyAuthorization
, SPublicKeyPins
, SRange
, SReferer
, SRetryAfter
, SSetCookie
, SStrictTransportSecurity
, STE
, STrailer
, STransferEncoding
, SUpgrade
, SUserAgent
, SVary
, SVia
, SWWWAuthenticate
, SWarning
, SXCsrfToken
, SXForwardedFor
, SXForwardedHost
, SXForwardedProto
)
, CustomHeader
, Accept
, AcceptCharset
, AcceptEncoding
, AcceptLanguage
, AcceptPatch
, AcceptRanges
, AccessControlAllowCredentials
, AccessControlAllowHeaders
, AccessControlAllowMethods
, AccessControlAllowOrigin
, AccessControlExposeHeaders
, AccessControlMaxAge
, AccessControlRequestHeaders
, AccessControlRequestMethod
, Age
, Allow
, Authorization
, CacheControl
, Connection
, ContentDisposition
, ContentEncoding
, ContentLanguage
, ContentLength
, ContentLocation
, ContentRange
, ContentSecurityPolicy
, ContentType
, Cookie
, Date
, ETag
, Expect
, Expires
, From
, Host
, IfMatch
, IfModifiedSince
, IfNoneMatch
, IfRange
, IfUnmodifiedSince
, LastModified
, Link
, Location
, MaxForwards
, Origin
, Pragma
, ProxyAuthenticate
, ProxyAuthorization
, PublicKeyPins
, Range
, Referer
, RetryAfter
, SetCookie
, StrictTransportSecurity
, TE
, Trailer
, TransferEncoding
, Upgrade
, UserAgent
, Vary
, Via
, WWWAuthenticate
, Warning
, XCsrfToken
, XForwardedFor
, XForwardedHost
, XForwardedProto
) where
import qualified Data.CaseInsensitive as CI
import Data.Singletons
import Data.Singletons.TypeLits
import Data.String
import Data.Text (Text)
import qualified Data.Text as T
data SomeHeaderName where
SomeHeaderName :: forall (h :: HeaderName) . Sing h -> SomeHeaderName
instance Show SomeHeaderName where
show (SomeHeaderName h) = "SomeHeaderName " ++ headerName h
instance Eq SomeHeaderName where
a == b = proj a == proj b where
proj :: SomeHeaderName -> CI.CI String
proj (SomeHeaderName h) = headerName h
instance Ord SomeHeaderName where
a `compare` b = proj a `compare` proj b where
proj :: SomeHeaderName -> CI.CI String
proj (SomeHeaderName h) = headerName h
instance IsString SomeHeaderName where
fromString = parseHeaderName . fromString
headerName :: forall s (h :: HeaderName) . IsString s => Sing h -> s
headerName h =
case h of
SCustomHeader sym -> withKnownSymbol sym (fromString $ symbolVal sym)
SAccept -> "Accept"
SAcceptCharset -> "Accept-Charset"
SAcceptEncoding -> "Accept-Encoding"
SAcceptLanguage -> "Accept-Language"
SAcceptPatch -> "Accept-Patch"
SAcceptRanges -> "Accept-Ranges"
SAccessControlAllowCredentials -> "Access-Control-Allow-Credentials"
SAccessControlAllowHeaders -> "Access-Control-Allow-Headers"
SAccessControlAllowMethods -> "Access-Control-Allow-Methods"
SAccessControlAllowOrigin -> "Access-Control-Allow-Origin"
SAccessControlExposeHeaders -> "Access-Control-Expose-Headers"
SAccessControlMaxAge -> "Access-Control-Max-Age"
SAccessControlRequestHeaders -> "Access-Control-Request-Headers"
SAccessControlRequestMethod -> "Access-Control-Request-Method"
SAge -> "Age"
SAllow -> "Allow"
SAuthorization -> "Authorization"
SCacheControl -> "Cache-Control"
SConnection -> "Connection"
SContentDisposition -> "Content-Disposition"
SContentEncoding -> "Content-Encoding"
SContentLanguage -> "Content-Language"
SContentLength -> "Content-Length"
SContentLocation -> "Content-Location"
SContentRange -> "Content-Range"
SContentSecurityPolicy -> "Content-Security-Policy"
SContentType -> "Content-Type"
SCookie -> "Cookie"
SDate -> "Date"
SETag -> "ETag"
SExpect -> "Expect"
SExpires -> "Expires"
SFrom -> "From"
SHost -> "Host"
SIfMatch -> "If-Match"
SIfModifiedSince -> "If-Modified-Since"
SIfNoneMatch -> "If-None-Match"
SIfRange -> "If-Range"
SIfUnmodifiedSince -> "If-Unmodified-Since"
SLastModified -> "Last-Modified"
SLink -> "Link"
SLocation -> "Location"
SMaxForwards -> "Max-Forwards"
SOrigin -> "Origin"
SPragma -> "Pragma"
SProxyAuthenticate -> "Proxy-Authenticate"
SProxyAuthorization -> "Proxy-Authorization"
SPublicKeyPins -> "Public-Key-Pins"
SRange -> "Range"
SReferer -> "Referer"
SRetryAfter -> "Retry-After"
SSetCookie -> "Set-Cookie"
SStrictTransportSecurity -> "Strict-Transport-Security"
STE -> "TE"
STrailer -> "Trailer"
STransferEncoding -> "Transfer-Encoding"
SUpgrade -> "Upgrade"
SUserAgent -> "User-Agent"
SVary -> "Vary"
SVia -> "Via"
SWWWAuthenticate -> "WWW-Authenticate"
SWarning -> "Warning"
SXCsrfToken -> "X-Csrf-Token"
SXForwardedFor -> "X-Forwarded-For"
SXForwardedHost -> "X-Forwarded-Host"
SXForwardedProto -> "X-Forwarded-Proto"
parseHeaderName :: CI.CI Text -> SomeHeaderName
parseHeaderName n =
case n of
"Accept" -> SomeHeaderName SAccept
"Accept-Charset" -> SomeHeaderName SAcceptCharset
"Accept-Encoding" -> SomeHeaderName SAcceptEncoding
"Accept-Language" -> SomeHeaderName SAcceptLanguage
"Accept-Patch" -> SomeHeaderName SAcceptPatch
"Accept-Ranges" -> SomeHeaderName SAcceptRanges
"Access-Control-Allow-Credentials" -> SomeHeaderName SAccessControlAllowCredentials
"Access-Control-Allow-Headers" -> SomeHeaderName SAccessControlAllowHeaders
"Access-Control-Allow-Methods" -> SomeHeaderName SAccessControlAllowMethods
"Access-Control-Allow-Origin" -> SomeHeaderName SAccessControlAllowOrigin
"Access-Control-Expose-Headers" -> SomeHeaderName SAccessControlExposeHeaders
"Access-Control-Max-Age" -> SomeHeaderName SAccessControlMaxAge
"Access-Control-Request-Headers" -> SomeHeaderName SAccessControlRequestHeaders
"Access-Control-Request-Method" -> SomeHeaderName SAccessControlRequestMethod
"Age" -> SomeHeaderName SAge
"Allow" -> SomeHeaderName SAllow
"Authorization" -> SomeHeaderName SAuthorization
"Cache-Control" -> SomeHeaderName SCacheControl
"Connection" -> SomeHeaderName SConnection
"Content-Disposition" -> SomeHeaderName SContentDisposition
"Content-Encoding" -> SomeHeaderName SContentEncoding
"Content-Language" -> SomeHeaderName SContentLanguage
"Content-Length" -> SomeHeaderName SContentLength
"Content-Location" -> SomeHeaderName SContentLocation
"Content-Range" -> SomeHeaderName SContentRange
"Content-Security-Policy" -> SomeHeaderName SContentSecurityPolicy
"Content-Type" -> SomeHeaderName SContentType
"Cookie" -> SomeHeaderName SCookie
"Date" -> SomeHeaderName SDate
"ETag" -> SomeHeaderName SETag
"Expect" -> SomeHeaderName SExpect
"Expires" -> SomeHeaderName SExpires
"From" -> SomeHeaderName SFrom
"Host" -> SomeHeaderName SHost
"If-Match" -> SomeHeaderName SIfMatch
"If-Modified-Since" -> SomeHeaderName SIfModifiedSince
"If-None-Match" -> SomeHeaderName SIfNoneMatch
"If-Range" -> SomeHeaderName SIfRange
"If-Unmodified-Since" -> SomeHeaderName SIfUnmodifiedSince
"Last-Modified" -> SomeHeaderName SLastModified
"Link" -> SomeHeaderName SLink
"Location" -> SomeHeaderName SLocation
"Max-Forwards" -> SomeHeaderName SMaxForwards
"Origin" -> SomeHeaderName SOrigin
"Pragma" -> SomeHeaderName SPragma
"Proxy-Authenticate" -> SomeHeaderName SProxyAuthenticate
"Proxy-Authorization" -> SomeHeaderName SProxyAuthorization
"Public-Key-Pins" -> SomeHeaderName SPublicKeyPins
"Range" -> SomeHeaderName SRange
"Referer" -> SomeHeaderName SReferer
"Retry-After" -> SomeHeaderName SRetryAfter
"Set-Cookie" -> SomeHeaderName SSetCookie
"Strict-Transport-Security" -> SomeHeaderName SStrictTransportSecurity
"TE" -> SomeHeaderName STE
"Trailer" -> SomeHeaderName STrailer
"Transfer-Encoding" -> SomeHeaderName STransferEncoding
"Upgrade" -> SomeHeaderName SUpgrade
"User-Agent" -> SomeHeaderName SUserAgent
"Vary" -> SomeHeaderName SVary
"Via" -> SomeHeaderName SVia
"WWW-Authenticate" -> SomeHeaderName SWWWAuthenticate
"Warning" -> SomeHeaderName SWarning
"X-Csrf-Token" -> SomeHeaderName SXCsrfToken
"X-Forwarded-For" -> SomeHeaderName SXForwardedFor
"X-Forwarded-Host" -> SomeHeaderName SXForwardedHost
"X-Forwarded-Proto" -> SomeHeaderName SXForwardedProto
other ->
case toSing (T.unpack (CI.original other)) :: SomeSing ('KProxy :: KProxy Symbol) of
SomeSing s -> SomeHeaderName (SCustomHeader s)
data HeaderName
= CustomHeader Symbol
| CacheControl
| Connection
| ContentLength
| ContentType
| Date
| Pragma
| Upgrade
| Via
| Warning
| Accept
| AcceptCharset
| AcceptEncoding
| AcceptLanguage
| AccessControlRequestMethod
| AccessControlRequestHeaders
| Authorization
| Cookie
| Expect
| From
| Host
| IfMatch
| IfModifiedSince
| IfNoneMatch
| IfRange
| IfUnmodifiedSince
| MaxForwards
| Origin
| ProxyAuthorization
| Range
| Referer
| TE
| UserAgent
| XForwardedFor
| XForwardedHost
| XForwardedProto
| XCsrfToken
| AccessControlAllowOrigin
| AccessControlExposeHeaders
| AccessControlMaxAge
| AccessControlAllowCredentials
| AccessControlAllowMethods
| AccessControlAllowHeaders
| AcceptPatch
| AcceptRanges
| Age
| Allow
| ContentDisposition
| ContentEncoding
| ContentLanguage
| ContentLocation
| ContentRange
| ContentSecurityPolicy
| ETag
| Expires
| LastModified
| Link
| Location
| ProxyAuthenticate
| PublicKeyPins
| RetryAfter
| SetCookie
| StrictTransportSecurity
| Trailer
| TransferEncoding
| Vary
| WWWAuthenticate
type CustomHeader s = 'CustomHeader s
type Accept = 'Accept
type AcceptCharset = 'AcceptCharset
type AcceptEncoding = 'AcceptEncoding
type AcceptLanguage = 'AcceptLanguage
type AcceptPatch = 'AcceptPatch
type AcceptRanges = 'AcceptRanges
type AccessControlAllowCredentials = 'AccessControlAllowCredentials
type AccessControlAllowHeaders = 'AccessControlAllowHeaders
type AccessControlAllowMethods = 'AccessControlAllowMethods
type AccessControlAllowOrigin = 'AccessControlAllowOrigin
type AccessControlExposeHeaders = 'AccessControlExposeHeaders
type AccessControlMaxAge = 'AccessControlMaxAge
type AccessControlRequestHeaders = 'AccessControlRequestHeaders
type AccessControlRequestMethod = 'AccessControlRequestMethod
type Age = 'Age
type Allow = 'Allow
type Authorization = 'Authorization
type CacheControl = 'CacheControl
type Connection = 'Connection
type ContentDisposition = 'ContentDisposition
type ContentEncoding = 'ContentEncoding
type ContentLanguage = 'ContentLanguage
type ContentLength = 'ContentLength
type ContentLocation = 'ContentLocation
type ContentRange = 'ContentRange
type ContentSecurityPolicy = 'ContentSecurityPolicy
type ContentType = 'ContentType
type Cookie = 'Cookie
type Date = 'Date
type ETag = 'ETag
type Expect = 'Expect
type Expires = 'Expires
type From = 'From
type Host = 'Host
type IfMatch = 'IfMatch
type IfModifiedSince = 'IfModifiedSince
type IfNoneMatch = 'IfNoneMatch
type IfRange = 'IfRange
type IfUnmodifiedSince = 'IfUnmodifiedSince
type LastModified = 'LastModified
type Link = 'Link
type Location = 'Location
type MaxForwards = 'MaxForwards
type Origin = 'Origin
type Pragma = 'Pragma
type ProxyAuthenticate = 'ProxyAuthenticate
type ProxyAuthorization = 'ProxyAuthorization
type PublicKeyPins = 'PublicKeyPins
type Range = 'Range
type Referer = 'Referer
type RetryAfter = 'RetryAfter
type SetCookie = 'SetCookie
type StrictTransportSecurity = 'StrictTransportSecurity
type TE = 'TE
type Trailer = 'Trailer
type TransferEncoding = 'TransferEncoding
type Upgrade = 'Upgrade
type UserAgent = 'UserAgent
type Vary = 'Vary
type Via = 'Via
type WWWAuthenticate = 'WWWAuthenticate
type Warning = 'Warning
type XCsrfToken = 'XCsrfToken
type XForwardedFor = 'XForwardedFor
type XForwardedHost = 'XForwardedHost
type XForwardedProto = 'XForwardedProto
data instance Sing (h :: HeaderName)
= forall s . h ~ CustomHeader s => SCustomHeader (Sing s)
| h ~ Accept => SAccept
| h ~ AcceptCharset => SAcceptCharset
| h ~ AcceptEncoding => SAcceptEncoding
| h ~ AcceptLanguage => SAcceptLanguage
| h ~ AcceptPatch => SAcceptPatch
| h ~ AcceptRanges => SAcceptRanges
| h ~ AccessControlAllowCredentials => SAccessControlAllowCredentials
| h ~ AccessControlAllowHeaders => SAccessControlAllowHeaders
| h ~ AccessControlAllowMethods => SAccessControlAllowMethods
| h ~ AccessControlAllowOrigin => SAccessControlAllowOrigin
| h ~ AccessControlExposeHeaders => SAccessControlExposeHeaders
| h ~ AccessControlMaxAge => SAccessControlMaxAge
| h ~ AccessControlRequestHeaders => SAccessControlRequestHeaders
| h ~ AccessControlRequestMethod => SAccessControlRequestMethod
| h ~ Age => SAge
| h ~ Allow => SAllow
| h ~ Authorization => SAuthorization
| h ~ CacheControl => SCacheControl
| h ~ Connection => SConnection
| h ~ ContentDisposition => SContentDisposition
| h ~ ContentEncoding => SContentEncoding
| h ~ ContentLanguage => SContentLanguage
| h ~ ContentLength => SContentLength
| h ~ ContentLocation => SContentLocation
| h ~ ContentRange => SContentRange
| h ~ ContentSecurityPolicy => SContentSecurityPolicy
| h ~ ContentType => SContentType
| h ~ Cookie => SCookie
| h ~ Date => SDate
| h ~ ETag => SETag
| h ~ Expect => SExpect
| h ~ Expires => SExpires
| h ~ From => SFrom
| h ~ Host => SHost
| h ~ IfMatch => SIfMatch
| h ~ IfModifiedSince => SIfModifiedSince
| h ~ IfNoneMatch => SIfNoneMatch
| h ~ IfRange => SIfRange
| h ~ IfUnmodifiedSince => SIfUnmodifiedSince
| h ~ LastModified => SLastModified
| h ~ Link => SLink
| h ~ Location => SLocation
| h ~ MaxForwards => SMaxForwards
| h ~ Origin => SOrigin
| h ~ Pragma => SPragma
| h ~ ProxyAuthenticate => SProxyAuthenticate
| h ~ ProxyAuthorization => SProxyAuthorization
| h ~ PublicKeyPins => SPublicKeyPins
| h ~ Range => SRange
| h ~ Referer => SReferer
| h ~ RetryAfter => SRetryAfter
| h ~ SetCookie => SSetCookie
| h ~ StrictTransportSecurity => SStrictTransportSecurity
| h ~ TE => STE
| h ~ Trailer => STrailer
| h ~ TransferEncoding => STransferEncoding
| h ~ Upgrade => SUpgrade
| h ~ UserAgent => SUserAgent
| h ~ Vary => SVary
| h ~ Via => SVia
| h ~ WWWAuthenticate => SWWWAuthenticate
| h ~ Warning => SWarning
| h ~ XCsrfToken => SXCsrfToken
| h ~ XForwardedFor => SXForwardedFor
| h ~ XForwardedHost => SXForwardedHost
| h ~ XForwardedProto => SXForwardedProto
instance SingI s => SingI ('CustomHeader s) where sing = SCustomHeader sing
instance SingI 'Accept where sing = SAccept
instance SingI 'AcceptCharset where sing = SAcceptCharset
instance SingI 'AcceptEncoding where sing = SAcceptEncoding
instance SingI 'AcceptLanguage where sing = SAcceptLanguage
instance SingI 'AcceptPatch where sing = SAcceptPatch
instance SingI 'AcceptRanges where sing = SAcceptRanges
instance SingI 'AccessControlAllowCredentials where sing = SAccessControlAllowCredentials
instance SingI 'AccessControlAllowHeaders where sing = SAccessControlAllowHeaders
instance SingI 'AccessControlAllowMethods where sing = SAccessControlAllowMethods
instance SingI 'AccessControlAllowOrigin where sing = SAccessControlAllowOrigin
instance SingI 'AccessControlExposeHeaders where sing = SAccessControlExposeHeaders
instance SingI 'AccessControlMaxAge where sing = SAccessControlMaxAge
instance SingI 'AccessControlRequestHeaders where sing = SAccessControlRequestHeaders
instance SingI 'AccessControlRequestMethod where sing = SAccessControlRequestMethod
instance SingI 'Age where sing = SAge
instance SingI 'Allow where sing = SAllow
instance SingI 'Authorization where sing = SAuthorization
instance SingI 'CacheControl where sing = SCacheControl
instance SingI 'Connection where sing = SConnection
instance SingI 'ContentDisposition where sing = SContentDisposition
instance SingI 'ContentEncoding where sing = SContentEncoding
instance SingI 'ContentLanguage where sing = SContentLanguage
instance SingI 'ContentLength where sing = SContentLength
instance SingI 'ContentLocation where sing = SContentLocation
instance SingI 'ContentRange where sing = SContentRange
instance SingI 'ContentSecurityPolicy where sing = SContentSecurityPolicy
instance SingI 'ContentType where sing = SContentType
instance SingI 'Cookie where sing = SCookie
instance SingI 'Date where sing = SDate
instance SingI 'ETag where sing = SETag
instance SingI 'Expect where sing = SExpect
instance SingI 'Expires where sing = SExpires
instance SingI 'From where sing = SFrom
instance SingI 'Host where sing = SHost
instance SingI 'IfMatch where sing = SIfMatch
instance SingI 'IfModifiedSince where sing = SIfModifiedSince
instance SingI 'IfNoneMatch where sing = SIfNoneMatch
instance SingI 'IfRange where sing = SIfRange
instance SingI 'IfUnmodifiedSince where sing = SIfUnmodifiedSince
instance SingI 'LastModified where sing = SLastModified
instance SingI 'Link where sing = SLink
instance SingI 'Location where sing = SLocation
instance SingI 'MaxForwards where sing = SMaxForwards
instance SingI 'Origin where sing = SOrigin
instance SingI 'Pragma where sing = SPragma
instance SingI 'ProxyAuthenticate where sing = SProxyAuthenticate
instance SingI 'ProxyAuthorization where sing = SProxyAuthorization
instance SingI 'PublicKeyPins where sing = SPublicKeyPins
instance SingI 'Range where sing = SRange
instance SingI 'Referer where sing = SReferer
instance SingI 'RetryAfter where sing = SRetryAfter
instance SingI 'SetCookie where sing = SSetCookie
instance SingI 'StrictTransportSecurity where sing = SStrictTransportSecurity
instance SingI 'TE where sing = STE
instance SingI 'Trailer where sing = STrailer
instance SingI 'TransferEncoding where sing = STransferEncoding
instance SingI 'Upgrade where sing = SUpgrade
instance SingI 'UserAgent where sing = SUserAgent
instance SingI 'Vary where sing = SVary
instance SingI 'Via where sing = SVia
instance SingI 'WWWAuthenticate where sing = SWWWAuthenticate
instance SingI 'Warning where sing = SWarning
instance SingI 'XCsrfToken where sing = SXCsrfToken
instance SingI 'XForwardedFor where sing = SXForwardedFor
instance SingI 'XForwardedHost where sing = SXForwardedHost
instance SingI 'XForwardedProto where sing = SXForwardedProto