Trait Endpoint

Source
pub trait Endpoint<AppState> {
    // Required methods
    fn path(&self) -> &'static str;
    fn method(&self) -> Method;
    fn bind_to(&self, router: Router<AppState>) -> Router<AppState>;
    fn body(&self) -> RequestStructure;
    fn res(&self) -> ResponseTapi;

    // Provided methods
    fn tys(&self) -> Vec<DynTapi> { ... }
    fn ts_client(&self) -> String { ... }
    fn js_client(&self) -> String { ... }
}

Required Methods§

Source

fn path(&self) -> &'static str

Source

fn method(&self) -> Method

Source

fn bind_to(&self, router: Router<AppState>) -> Router<AppState>

Source

fn body(&self) -> RequestStructure

Source

fn res(&self) -> ResponseTapi

Provided Methods§

Source

fn tys(&self) -> Vec<DynTapi>

Source

fn ts_client(&self) -> String

Generate a TypeScript client for this endpoint.

The generated client will look something like this:

export const api = {
    index: request<{}, string>("none", "GET", "/", "text"),
    api: request<Person, string>("json", "GET", "/api", "json"),
    api2AB: request<{}, string>("none", "GET", "/api2/:a/:b", "text"),
    wow: sse<Msg>("/wow", "json"),
    cool: request<Record<string, string>, Msg>("json", "GET", "/cool", "json"),
};
Source

fn js_client(&self) -> String

Implementations on Foreign Types§

Source§

impl<'a, AppState, T> Endpoint<AppState> for &'a T
where T: Endpoint<AppState>,

Source§

fn path(&self) -> &'static str

Source§

fn method(&self) -> Method

Source§

fn bind_to(&self, router: Router<AppState>) -> Router<AppState>

Source§

fn body(&self) -> RequestStructure

Source§

fn res(&self) -> ResponseTapi

Implementors§