package ldp

  1. Overview
  2. Docs

Providing high-level HTTP queries.

module Ldp = Rdf.Ldp
val user_agent : string Stdlib.ref

String added in query header "User-agent".

type query_error = Cohttp.Code.meth * int * Types.meta
type Types.error +=
  1. | Query_error of query_error
val string_of_query_error : query_error -> string
val container_types : Iri.Set.t

The set of known container types.

val type_is_container : Iri.t -> bool

type_is_container iri returns whether iri is a container type, comparing to known container_types.

val is_container : ?iri:Iri.t -> Rdf.Graph.graph -> bool

is_container ~iri g returns whether iri is a container, according to graph g. If iri is not provided, the name if the graph is used intead.

val response_metadata : Iri.t -> (Cohttp.Response.t * Cohttp_lwt.Body.t) -> Types.meta

response_metadata iri (resp, body) creates a Types.meta structure with the given iri and from the http response and body.

val parse_graph : ?g:Rdf.Graph.graph -> Iri.t -> Ct.t -> string -> (Rdf.Graph.graph, Types.error) Stdlib.result

parse_graph iri content_type body tries to parse graph in body according to the content_type. If no graph g is provided, a new one with name iri is created. The graph (the enriched graph or the created one) or an error is returned.

Abstraction of HTTP requests

module type Requests = sig ... end
exception Not_initialized of string
val dummy_requests : string -> (module Requests)

dummy_request name returns a module which can be used in applications instead of a normal Requests module, typically before some initializations. dbg does nothing and call will raise Not_initialized name.

Caching

module type Cache = sig ... end
type cache_find_response =
  1. | Not_found
    (*

    The resource was not found in cache.

    *)
  2. | Found of Cohttp.Response.t * string
    (*

    The resource was found in cache, with the given response and body as string.

    *)
  3. | If_error of Cohttp.Response.t -> string -> (Cohttp.Response.t * string) Lwt.t
    (*

    The resource is in the cache, but it should be used only in case of error after performing the request.

    *)

The different ways the find function of a cache implementation can respond.

module type Cache_impl = sig ... end

Creates a cache from implementation of cache operations.

module No_cache : Cache

A cache caching nothing, i.e. key always returns None.

High-level HTTP

The high-level HTTP module created from a Requests implementation.

module type Http = sig ... end
module Cached_http (C : Cache) (_ : Requests) : Http

Creates a Http module using the given cache.

module Http (_ : Requests) : Http

Specialized HTTP queries

These are queries used to send and receive data of a given content-type. The following module types and the Http_ct module can be used to create functions to perform such queries.

module type Ct_wrapper = sig ... end

Mapping values of a given content-type to and from strings.

module type Http_ct = sig ... end

The type of the module with specialized query functions.

module Http_ct (H : Http) (W : Ct_wrapper) : Http_ct with type t = W.t

Creating a module to perform specialized queries over the given Http module. See the corresponding functions in Http for more information about arguments.

OCaml

Innovation. Community. Security.