package ldp

  1. Overview
  2. Docs

Base types and utilities.

Resources

type meta = {
  1. iri : Iri.t;
    (*

    IRI of the resource

    *)
  2. acl : Iri.t option;
    (*

    Optional IRI of the ACL (access control list) of the resource.

    *)
  3. meta : Iri.t option;
    (*

    Optional IRI of meta information about the resource.

    *)
  4. user : string option;
    (*

    Optional used identifier when resource was retrieved.

    *)
  5. websocket : Iri.t option;
    (*

    Optional IRI of a websocket tunnel for the resource.

    *)
  6. editable : Cohttp.Code.meth list;
    (*

    Allowed HTTP methods on the resource.

    *)
  7. exists : bool;
    (*

    Whether the resource exists.

    *)
  8. info : Cohttp.Response.t * Cohttp_lwt.Body.t;
    (*

    Original HTTP response and body.

    *)
}

Information about a resource.

val meta : ?acl:Iri.t -> ?meta:Iri.t -> ?user:string -> ?websocket:Iri.t -> ?editable:Cohttp.Code.meth list -> ?exists:bool -> Cohttp.Response.t -> Cohttp_lwt.Body.t -> Iri.t -> meta

meta resp body creates a meta structure. Optional fields have default value None. Default editable is []. Default exists is true.

val string_of_meta : meta -> string

Returns a string representation of a Types.meta, mainly for debugging purpose;

type rdf_resource = {
  1. meta : meta;
  2. graph : Rdf.Graph.graph;
  3. ct : Ct.t;
  4. contents : string;
}

A RDF resource contains meta information on the resource, its graph, content-type and original contents as a string.

type non_rdf_resource = {
  1. meta : meta;
  2. ct : Ct.t;
  3. contents : string;
}

A Non-rdf resource contains meta information on the resource, its content-type and its original contents as a string.

type resource =
  1. | Container of rdf_resource
  2. | Rdf of rdf_resource
  3. | Non_rdf of non_rdf_resource

A resource may be a container, another RDF resource or a non-RDF resource.

val container_children : Rdf.Graph.graph -> Iri.t list

container_children g returns the IRIs of the children of the given container. Container IRI is the name of the graph. Its children are retrieved by looking for the triples with the name of the graph as subjects and the Rdf.Ldp.contains relation.

Errors

type error = ..

The error type, with constructors added by other modules.

exception Error of error

Exception used in the library to signal an error.

val error : error -> 'a

error e raises a Error exception with the given error.

val fail : error -> 'a Lwt.t

fail e calls Lwt.fail with a Error exception with the given error.

val string_of_error : error -> string

Returns a string representation of the given error.

val register_string_of_error : ((error -> string) -> error -> string) -> unit

register_string_of_error f registers f as printer for errors. f takes the previous printer function, to use it as fallback for errors not handled.

type error +=
  1. | Invalid_method of string
  2. | Missing_pred of Iri.t * Iri.t
  3. | Missing_pred_iri of Iri.t * Iri.t
  4. | Request_error of Iri.t * string
  5. | Parse_error of Iri.t * exn
  6. | Unsupported_format of Iri.t * Ct.mime

Misc

val content_type_of_string : ?fail:bool -> string -> Ct.t

content_type_of_string str parses str as content-type, using Ldp.Ct.of_string. If parsing fails and fail is true (which is the default), raises Failure with the error message, else return the default content-type Ldp.Ct.default.

val split_string : ?keep_empty:bool -> string -> char list -> string list

split_string string chars splits the given string on any of the chars. Optional argument keep_empty (default is false) indicates whether empty strings must be returned too.

val methods_of_string : string -> Cohttp.Code.meth list

methods_of_string str returns the list of HTTP methods from the given string str, where they may be separated by characters ',', ' ' or '\t'.

OCaml

Innovation. Community. Security.