@hackage network-uri-template0.1.1.4

Library for parsing and expanding URI Templates, as per RFC 6570

As per the RFC,

For example, the following URI Template includes a form-style
parameter expression, as indicated by the "?" operator appearing
before the variable names.


http:/www.example.comfoo{?query,number}


The expansion process for expressions beginning with the question-
mark ("?") operator follows the same pattern as form-style interfaces
on the World Wide Web:


http:/www.example.comfoo{?query,number}
_____________/
|
|
For each defined variable in [ query, number ],
substitute "?" if it is the first substitution or "&"
thereafter, followed by the variable name, =, and the
variable's value.


If the variables have the values


query  := "mycelium"
number := 100


then the expansion of the above URI Template is


http:/www.example.comfoo?query=mycelium&number=100


Alternatively, if query is undefined, then the expansion would be


http:/www.example.comfoo?number=100


or if both variables are undefined, then it would be


http:/www.example.comfoo

This library handles expanding such templates.