package virtual_dom

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

The Uri_routing module is common to your server and your client. The server needs to call it because it should only serve up your client.html if routing succeeds. You shouldn't unconditionally serve the homepage and rely on the client javascript to filter out bad uris, because it means you'll serve up junk for favicon.ico and robots.txt etc.

type t

Uri_routing.t is typically a variant type describing which page the user has browsed to.

It's up to you whether or not you include a constructor for your static files, or have your server serve them up before it considers Uri_routing.parse.

include Ppx_compare_lib.Equal.S with type t := t
val equal : t -> t -> bool
val sexp_of_t : t -> Sexplib0.Sexp.t
val parse : Uri.t -> (t, [ `Not_found ]) Core.Result.t

parse should probably inspect only the path and maybe the query.

val to_path_and_query : t -> Uri.t

It's strongly encouraged for to_path_and_query to produce a URI without the scheme or host (i.e, only provide the path); it will be handed to push_or_replace and the browser will resolve it relative to the current URI, as mentioned above.

If the URI produced has e.g. a host in it, and is not of the same origin as the current page, push_or_replace will raise.