terminus

A generic client to interact with Rest API
Legend:
Library
Module
Module type
Parameter
Class
Class type
Library terminus
Module Terminus . Mock
type query =
| Get of string
| Post of string * string
| Put of string * string
| Delete of string

The query type defines the interaction with the API:

  • Get path: tries to execute the GET method on a specific path in the API
  • Post (path, expected) defines a POST method on a path and verify the input with expected.
  • Put (path, expected) works the same way as Post
  • Delete path executes a DELETE method on a specific path
exception Wrong_url of string

Exception raised when you are trying to execute a request on a wrong url or when urls mismatched.

exception Wrong_header of string

Exception raised when on field in an header mismatch.

module type Mock_backend = sig ... end

A Mock backend is an implementation of the S module with a mock backend.

val mock : address:string -> expected_headers:(string * string) list -> expect:(query * string) list -> unit -> (module Mock_backend)

mock ~address ~expected_headers ~expect () creates a new mock backend with some checks in it. The address is the endpoint for the API. the expected_headers are the data that should be found at each request in the header. expect is a list of query with the answer expected when you execute the request.