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§
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>
Sourcefn ts_client(&self) -> String
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"),
};