Uri_parsing.ParserSourceinclude Uri_parser_intfYou should have an expect test with this just below your routes definition, so that you can see what your URL scheme looks like, and/or any errors.
Runs static checks, and shows all of the url shapes that the parser can parse. It lets you know if a URL shape sneakily changes or if there is any ambiguity in your parser. It tries its best to suggest possible fixes too.
val eval :
?encoding_behavior:Percent_encoding_behavior.t ->
'a t ->
(Components.t, 'a Parse_result.t) Projection.t"Evaluates" a 'a t into a projection that parses to/from Components.t to 'a Parse_result.t.
val eval_for_uri :
?encoding_behavior:Percent_encoding_behavior.t ->
'a t ->
(Uri.t, 'a Parse_result.t) Projection.tLike eval but parses/unparses from/into a Uri.t
Creates a URL that you can attach to an a tag as an href to reference another URL from your site. The function is staged because it "evaluates" the parser which _could_ be an expensive operation.
Returns a list of the shapes of all the URLs given that the parser can parse.
Like Value_parser.project, but works at the Parser.t level.
Runs the given 'a t, if at any point its given parse fails due to a missing query_field, this fill parse into None, otherwise, this will parse into Some (* What 'a t would've parsed to *).
When this parses to None, the components that will be given to the next parse will be the same ones that optional_query_fields received, as if it were a no-op regardless if a subset of the parser suceeded.
Looks up a key from components. If it's missing, parsing fails.
The key is determined with the following priority: 1. If ?key is given, then the given key is used. 2. If the parser is inside of a record or variant parser, then the field name/constructor name that the parser name is in will be the key that is used. 3. Key can't be inferred and an exception will be raised.
If you use check_ok_and_print_urls_or_errors, your parser will statically fail in an expect test, rather than failing on runtime.
Like from_query_required, but parses into None if key is missing from URL's query.
val from_query_optional_with_default :
?key:string ->
equal:('a -> 'a -> bool) ->
'a Value_parser.t ->
default:'a ->
'a tLike from_query_required, but parses into the 'a default value that's given to it.
if equal is passed over, when the unparsing occurs, if equal curr_value default_value, then the key/value pair is not included in the URL.
Like from_query_required, but will parse into a list of values rather than just one. (e.g. ?foo=1,2,3,4 => 1; 2; 3; 4) with from_query_many ~key:"foo" Value_parser.int
from_query_many ~key:"q" Value_parser.int parses into:
"?q=1,2,3" => 1; 2; 3 "?q=1" => 1 "?q" => "?" =>
Like from_query_many, but fails if there is not a single element in the list.
No-op parser, does not consume anything. Useful for Variants that don't have a payload.
Reads the next value that is available in the path, parses it, and removes it from the path so that the next parsers move on an parse the remainder of the path.
from_paths equivalent of from_query_many. Like from_path except that instead of just taking one element from the path list, it will take everything from the path list and run the given 'a Value_parser.t through it.
with_prefix prefix next will fail if the path that it receives does not start with prefix. If there is a prefix match, then next will continue parsing.
with_remaining_path is just like with_prefix just that instead of only needing the string list that it receives to match like a prefix, the entire path needs to equal the string that its given. No more path parsing is allowed inside of the parser that's given to with_remaining_path.
Fails to parse if path is not empty. If path is empty, its input parser continues parsing. end_of_path next is equivalent to with_remaining_path [] next.
This module is like the Variant module, but instead of picking the variant based on the path of the url, it is instead picked based on the value of a query field.