Safe Haskell | None |
---|
- type QueryItem = (ByteString, Maybe ByteString)
- type Query = [QueryItem]
- type SimpleQueryItem = (ByteString, ByteString)
- type SimpleQuery = [SimpleQueryItem]
- simpleQueryToQuery :: SimpleQuery -> Query
- renderQuery :: Bool -> Query -> ByteString
- renderQueryBuilder :: Bool -> Query -> Builder
- renderSimpleQuery :: Bool -> SimpleQuery -> ByteString
- parseQuery :: ByteString -> Query
- parseSimpleQuery :: ByteString -> SimpleQuery
- type QueryText = [(Text, Maybe Text)]
- queryTextToQuery :: QueryText -> Query
- queryToQueryText :: Query -> QueryText
- renderQueryText :: Bool -> QueryText -> Builder
- parseQueryText :: ByteString -> QueryText
- encodePathSegments :: [Text] -> Builder
- decodePathSegments :: ByteString -> [Text]
- encodePathSegmentsRelative :: [Text] -> Builder
- encodePath :: [Text] -> Query -> Builder
- decodePath :: ByteString -> ([Text], Query)
- urlEncodeBuilder :: Bool -> ByteString -> Builder
- urlEncode :: Bool -> ByteString -> ByteString
- urlDecode :: Bool -> ByteString -> ByteString
Query string
type QueryItem = (ByteString, Maybe ByteString)Source
Query item
type Query = [QueryItem]Source
Query.
General form: a=b&c=d, but if the value is Nothing, it becomes a&c=d.
type SimpleQueryItem = (ByteString, ByteString)Source
Simplified Query item type without support for parameter-less items.
type SimpleQuery = [SimpleQueryItem]Source
Simplified Query type without support for parameter-less items.
simpleQueryToQuery :: SimpleQuery -> QuerySource
Convert SimpleQuery
to Query
.
Convert Query
to a Builder
.
:: Bool | prepend question mark? |
-> SimpleQuery | |
-> ByteString |
Convert SimpleQuery
to ByteString
.
parseQuery :: ByteString -> QuerySource
Split out the query string into a list of keys and values. A few importants points:
parseSimpleQuery :: ByteString -> SimpleQuerySource
Parse SimpleQuery
from a ByteString
.
Text query string (UTF8 encoded)
type QueryText = [(Text, Maybe Text)]Source
Like Query, but with Text
instead of ByteString
(UTF8-encoded).
parseQueryText :: ByteString -> QueryTextSource
Parse QueryText
from a ByteString
. See parseQuery
for details.
Path segments
encodePathSegments :: [Text] -> BuilderSource
Encodes a list of path segments into a valid URL fragment.
This function takes the following three steps:
- UTF-8 encodes the characters.
- Performs percent encoding on all unreserved characters, as well as :@=+$,
- Prepends each segment with a slash.
For example:
encodePathSegments [\"foo\", \"bar\", \"baz\"]
"/foo/bar/baz"
encodePathSegments [\"foo bar\", \"baz\/bin\"]
"/foo%20bar/baz%2Fbin"
encodePathSegments [\"שלום\"]
"/%D7%A9%D7%9C%D7%95%D7%9D"
Huge thanks to Jeremy Shaw who created the original implementation of this function in web-routes and did such thorough research to determine all correct escaping procedures.
decodePathSegments :: ByteString -> [Text]Source
Parse a list of path segments from a valid URL fragment.
encodePathSegmentsRelative :: [Text] -> BuilderSource
Like encodePathSegments, but without the initial slash.
Path (segments + query string)
encodePath :: [Text] -> Query -> BuilderSource
Encode a whole path (path segments + query).
decodePath :: ByteString -> ([Text], Query)Source
Decode a whole path (path segments + query).
URL encoding / decoding
:: Bool | Whether input is in query string. True: Query string, False: Path element |
-> ByteString | |
-> Builder |
Percent-encoding for URLs (using Builder
).
urlEncode :: Bool -> ByteString -> ByteStringSource
Percent-encoding for URLs.