package ezresto

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

Paths describe URIs/URLs: segments separated by slashes (/).

Note that paths can be static (i.e., all the segments of the path are determined in advance) or dynamic (i.e., some segments of the path are actually arguments for the service -- e.g., paths can have the form /user/<user-name> where <user-name> is a string encoding of a user identifier).

type 'params t = (unit, 'params) Resto.Path.path

The type for service's paths

A a path is a path in which some segments encode a value of type a.

Typically a unit path is a static path. Also typically, a dynamic path has type (((unit * a) * b) * ..) path where different segments encode the different components of the tuple (a, b, etc.). For example the path /entries-by-date/<year>/<month>/<day> may be described as a (((unit * int) * int) * int) path.

type 'params path = 'params t
val root : unit path

root is the Nil of path construction.

val add_suffix : 'params path -> string -> 'params path

add_suffix p s is a path in which s has been appended to the sequence of segments described by p.

val (/) : 'params path -> string -> 'params path
val add_arg : 'params path -> 'a Arg.arg -> ('params * 'a) path

add_arg p a is a path in which a segment representing a value of type a has been appended to the sequence of segments described by p.

This is intended for use by services with parameters. Specifically, a service that is parametrized over a value of type a is attached to a path that includes a argument for a value of type a. When the service is called, the argument is encoded as by the client/decoded by the server, using the constructor/destructor of the argument.

val (/:) : 'params path -> 'a Arg.arg -> ('params * 'a) path
OCaml

Innovation. Community. Security.