pub trait EndpointDetails {
type RequestType: PayloadTrait;
type ResponseType: ResultPayloadTrait;
const METHOD: Method;
const PATH: &'static str;
// Provided methods
fn immutable_response() -> bool { ... }
fn add_to<App, F, Args: FromRequest + 'static>(
app: &Rc<App>,
sc: &mut ServiceConfig,
handler: F,
)
where AppMethod<App, F, Self>: Handler<Args>,
<AppMethod<App, F, Self> as Handler<Args>>::Output: 'static + Responder { ... }
fn caching_add_to<App, F>(app: &Rc<App>, sc: &mut ServiceConfig, handler: F)
where F: Fn(&App) -> Self::ResponseType,
Self: Sized + 'static { ... }
}Expand description
Details on a PubHubs server endpoint
Required Associated Constants§
Required Associated Types§
Provided Methods§
Sourcefn immutable_response() -> bool
fn immutable_response() -> bool
Can the response be cached indefinitely?
Sourcefn add_to<App, F, Args: FromRequest + 'static>(
app: &Rc<App>,
sc: &mut ServiceConfig,
handler: F,
)
fn add_to<App, F, Args: FromRequest + 'static>( app: &Rc<App>, sc: &mut ServiceConfig, handler: F, )
Helper function to add this endpoint to a web::ServiceConfig.
The handler argument must be of the form:
async fn f(app : Rc<App>, ...) -> api::ResponseTypeThe ... can contain arguments of type actix_web::FromRequest.
Sourcefn caching_add_to<App, F>(app: &Rc<App>, sc: &mut ServiceConfig, handler: F)
fn caching_add_to<App, F>(app: &Rc<App>, sc: &mut ServiceConfig, handler: F)
Like add_to, but runs handler only once, caching the result.
Of course, handler won’t have access to the usual actix_web::FromRequest arguments,
as there is no request to derive these arguments from.
Moreover handler cannot be async, since actix_web::App::configure takes a non-async
function.
Only application/json responses are supported.
§handler errors and panics
If handler returns an Err, then this will not cause the App (and associated Server) to
crash. Instead the Err is cached and served to any client requesting this endpoint.
If a crash is desirable, then handler should panic. Unlike a panic in a regular
actix_web::Handler (which will just cause a connection reset), a panic here will cause
the Server to exit.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.