pub trait RestApiEndpoint {
    type RequestBody;

    fn method(&self) -> Result<Method, Error>;
    fn url(&self, base_url: &Url) -> Result<Url, Error>;
    fn request_body(&self) -> Result<Option<Cow<'_, Self::RequestBody>>, Error>
    where
        Self::RequestBody: Clone + Serialize + Debug
; }
Expand description

a trait for objects describing a REST API endpoint

this is implemented by types which contain all the necessary information for a request.

Required Associated Types

the type of the request body

Required Methods

returns the HTTP method to use

since this is Icinga this is the method passed to X-HTTP-Method-Override

the actual HTTP method will always be POST if there is a request body

Errors

this should return an error if something went wrong in determining the request method

returns the URL to use for the request based on the base URL passed in as a parameter

Errors

this should return an error if something went wrong in determining the URL (e.g. parse error on the fragment joined to the base URL)

the request body which must be a JSON serializable type

since it is always JSON we do not need to return a Content-Type

Errors

this should return an error if something went wrong in determining the request body

Implementors