package resto

  1. Overview
  2. Docs
A minimal OCaml library for type-safe HTTP/JSON RPCs

Install

Dune Dependency

Authors

Maintainers

Sources

resto-v1.2.tar.gz
md5=e8f71db769f34d755669dbf6595ead0f
sha512=454e7f3a43c5d0ef38701103b74dad5b6dc2db1add1e2665ea679e6a1df72d37f3a092eedda0bb86949e408bff52772eb0a18901fa70860b17c5bec7f96e0170

doc/resto/Resto/index.html

Module RestoSource

Sourcemodule Utils : sig ... end

Resto

Resto is a library for defining, serving, and querying a REST directory of RPC services.

Overview of Resto

Resto is a library for describing *services*. A service is the entry-point in an API: a URI/URL with some path parameters (some of the slash-separated segments are actually decoded as parameters), some additional query parameters (the part that looks like ?utm_parameter=from_email in the links of marketing emails) and other attributes depending on the method of the service.

For example, you can use Resto to describe the directory of services that, as a whole, forms the API for a web-service. You can then use one of the other resto packages to implement a server that answers requests made to this API. Alternatively, you can use one of the other resto packages to make your program query such an API.

Intended use of Resto

The intended use of Resto is as follows:

  • Define arguments, paths, query fields, and queries as required by the API you describe.
  • Define services using the previously defined arguments, paths, query fields and queries.
  • Use Resto_directory to register those services.

If you are writing a server, you can then:

  • Use Resto_cohttp_server.Server to spin up a server that answers requests to these services.

Alternatively, if you are writing a client, you can then:

  • Use Resto_cohttp_client.Client to make requests to these services.

And of course you can do both if you are writing both the server and the client.

Sourcetype meth = [
  1. | `GET
  2. | `POST
  3. | `DELETE
  4. | `PUT
  5. | `PATCH
]

The different methods that a service can be used by a service.

Sourceval string_of_meth : [< meth ] -> string
Sourceval meth_of_string : string -> [> meth ] option
Sourcemodule MethMap : Map.S with type key = meth
Sourcemodule StringMap : Map.S with type key = string
Sourcetype (_, _) eq =
  1. | Eq : ('a, 'a) eq

eq is an equality witness type. It is returned by some non-trivial equality-testing functions in the rest of this module. In general, it is intended to be used as follows:

match are_equal foo bar with | None -> (* values are not equal *) .. | Some Eq -> (* values are equal *) ..

Sourcemodule Arg : sig ... end

Arguments are documented serializers-deserializers for parameters.

Sourcemodule Path : sig ... end

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

Sourcemodule Description : sig ... end

Service directory description

Sourcemodule Query : sig ... end

Query parameters are the key-value pairs that appear as ?key0=value0&key1=value1&.. at the end of the path in URIs/URLs.

Sourcemodule type ENCODING = sig ... end

An ENCODING is a generic interface for modules that provide conversion from values to a different representation and back. This is used to abstract resto over specific representations of values.

Sourcemodule MakeService (Encoding : ENCODING) : sig ... end

Services.

OCaml

Innovation. Community. Security.