This module contains a structure for representing web URLs. We don't try
to be a fully general URI parser (so no mailto:
etc), but it's a lot
better than Network.URI for dealing with HTTP(S)
- data URL = URL {}
- data RelativeURL = RelativeURL {}
- data Scheme
- data Host
- toRelative :: URL -> RelativeURL
- parse :: ByteString -> Maybe URL
- parseRelative :: ByteString -> Maybe RelativeURL
- parseArguments :: ByteString -> Maybe (Map ByteString ByteString)
- serialise :: URL -> ByteString
- serialiseRelative :: RelativeURL -> ByteString
- serialiseArguments :: Map ByteString ByteString -> ByteString
Documentation
A web URL
URL | |
|
data RelativeURL Source
This is a relative URL. It just copies (and renames) the last three members of URL. However, it's good to keep these two different types of URL apart in the type system.
RelativeURL | |
|
The host where the resource can be found
toRelative :: URL -> RelativeURLSource
Extract a relative URL from a URL
parse :: ByteString -> Maybe URLSource
Parse a URL
parseRelative :: ByteString -> Maybe RelativeURLSource
Parse a relative URL
parseArguments :: ByteString -> Maybe (Map ByteString ByteString)Source
Parse just an arguments map. Can be useful for POST requests. Warning: it occurs to be that the arguments in a POST request might include unescaped '#' symbols. In a URL that would be illegal, but the parser may need to be reworked for that.
serialise :: URL -> ByteStringSource
Convert a URL to a ByteString. It's the same as show, except for the type of the return.
serialiseArguments :: Map ByteString ByteString -> ByteStringSource
Serialise just an arguments map. Can be useful for POST requests.