Skip to main content

EndpointDetails

Trait EndpointDetails 

Source
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§

Source

const METHOD: Method

Source

const PATH: &'static str

Required Associated Types§

Provided Methods§

Source

fn immutable_response() -> bool

Can the response be cached indefinitely?

Source

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,

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::ResponseType

The ... can contain arguments of type actix_web::FromRequest.

Source

fn caching_add_to<App, F>(app: &Rc<App>, sc: &mut ServiceConfig, handler: F)
where F: Fn(&App) -> Self::ResponseType, Self: Sized + 'static,

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.

Implementors§

Source§

impl EndpointDetails for pubhubs::api::admin::InfoEP

Source§

const METHOD: Method = http::Method::POST

Source§

const PATH: &'static str = ".ph/admin/info"

Source§

type RequestType = Signed<InfoReq>

Source§

type ResponseType = Result<InfoResp, ErrorCode>

Source§

impl EndpointDetails for UpdateConfigEP

Source§

const METHOD: Method = http::Method::POST

Source§

const PATH: &'static str = ".ph/admin/update-config"

Source§

type RequestType = Signed<UpdateConfigReq>

Source§

type ResponseType = Result<UpdateConfigResp, ErrorCode>

Source§

impl EndpointDetails for AttrKeysEP

Source§

const METHOD: Method = http::Method::POST

Source§

const PATH: &'static str = ".ph/attr-keys"

Source§

type RequestType = HashMap<Handle, AttrKeyReq>

Source§

type ResponseType = Result<AttrKeysResp, ErrorCode>

Source§

impl EndpointDetails for AuthCompleteEP

Source§

const METHOD: Method = http::Method::POST

Source§

const PATH: &'static str = ".ph/auth/complete"

Source§

type RequestType = AuthCompleteReq

Source§

type ResponseType = Result<AuthCompleteResp, ErrorCode>

Source§

impl EndpointDetails for AuthStartEP

Source§

const METHOD: Method = http::Method::POST

Source§

const PATH: &'static str = ".ph/auth/start"

Source§

type RequestType = AuthStartReq

Source§

type ResponseType = Result<AuthStartResp, ErrorCode>

Source§

impl EndpointDetails for CardEP

Source§

const METHOD: Method = http::Method::POST

Source§

const PATH: &'static str = ".ph/card"

Source§

type RequestType = CardReq

Source§

type ResponseType = Result<CardResp, ErrorCode>

Source§

impl EndpointDetails for pubhubs::api::auths::WelcomeEP

Source§

const METHOD: Method = http::Method::GET

Source§

const PATH: &'static str = ".ph/welcome"

Source§

type RequestType = NoPayload

Source§

type ResponseType = Result<WelcomeResp, ErrorCode>

Source§

impl EndpointDetails for YiviReleaseNextSessionEP

Source§

const METHOD: Method = http::Method::POST

Source§

const PATH: &'static str = ".ph/yivi/release-next-session"

Source§

type RequestType = YiviReleaseNextSessionReq

Source§

type ResponseType = Result<YiviReleaseNextSessionResp, ErrorCode>

Source§

impl EndpointDetails for YiviWaitForResultEP

Source§

const METHOD: Method = http::Method::POST

Source§

const PATH: &'static str = ".ph/yivi/wait-for-result"

Source§

type RequestType = YiviWaitForResultReq

Source§

type ResponseType = Result<YiviWaitForResultResp, ErrorCode>

Source§

impl EndpointDetails for EnterCompleteEP

Source§

const METHOD: Method = http::Method::POST

Source§

const PATH: &'static str = ".ph/enter-complete"

Source§

type RequestType = EnterCompleteReq

Source§

type ResponseType = Result<EnterCompleteResp, ErrorCode>

Source§

impl EndpointDetails for EnterStartEP

Source§

const METHOD: Method = http::Method::POST

Source§

const PATH: &'static str = ".ph/enter-start"

Source§

type RequestType = NoPayload

Source§

type ResponseType = Result<EnterStartResp, ErrorCode>

Source§

impl EndpointDetails for pubhubs::api::hub::InfoEP

Source§

const METHOD: Method = http::Method::GET

Source§

const PATH: &'static str = ".ph/info"

Source§

type RequestType = NoPayload

Source§

type ResponseType = Result<InfoResp, ErrorCode>

Source§

impl EndpointDetails for TicketEP

Source§

const METHOD: Method = http::Method::POST

Source§

const PATH: &'static str = ".ph/hub/ticket"

Source§

type RequestType = Signed<TicketReq>

Source§

type ResponseType = Result<TicketResp, ErrorCode>

Source§

impl EndpointDetails for CachedHubInfoEP

Source§

const METHOD: Method = http::Method::GET

Source§

const PATH: &'static str = ".ph/user/cached-hub-info"

Source§

type RequestType = NoPayload

Source§

type ResponseType = Result<CachedHubInfoResp, ErrorCode>

Source§

impl EndpointDetails for CardPseudEP

Source§

const METHOD: Method = http::Method::POST

Source§

const PATH: &'static str = ".ph/user/card-pseud"

Source§

type RequestType = NoPayload

Source§

type ResponseType = Result<CardPseudResp, ErrorCode>

Source§

impl EndpointDetails for EnterEP

Source§

const METHOD: Method = http::Method::POST

Source§

const PATH: &'static str = ".ph/user/enter"

Source§

type RequestType = EnterReq

Source§

type ResponseType = Result<EnterResp, ErrorCode>

Source§

impl EndpointDetails for GetObjectEP

Source§

const METHOD: Method = http::Method::GET

Source§

const PATH: &'static str = ".ph/user/obj/by-hash/{hash}/{hmac}"

Source§

type RequestType = NoPayload

Source§

type ResponseType = Payload<Result<GetObjectResp, ErrorCode>>

Source§

impl EndpointDetails for HhppEP

Source§

const METHOD: Method = http::Method::POST

Source§

const PATH: &'static str = ".ph/user/hhpp"

Source§

type RequestType = HhppReq

Source§

type ResponseType = Result<HhppResp, ErrorCode>

Source§

impl EndpointDetails for NewObjectEP

Source§

const METHOD: Method = http::Method::POST

Source§

const PATH: &'static str = ".ph/user/obj/by-handle/{handle}"

Source§

type RequestType = BytesPayload

Source§

type ResponseType = Result<StoreObjectResp, ErrorCode>

Source§

impl EndpointDetails for OverwriteObjectEP

Source§

const METHOD: Method = http::Method::POST

Source§

const PATH: &'static str = ".ph/user/obj/by-hash/{handle}/{overwrite_hash}"

Source§

type RequestType = BytesPayload

Source§

type ResponseType = Result<StoreObjectResp, ErrorCode>

Source§

impl EndpointDetails for PppEP

Source§

const METHOD: Method = http::Method::POST

Source§

const PATH: &'static str = ".ph/user/ppp"

Source§

type RequestType = NoPayload

Source§

type ResponseType = Result<PppResp, ErrorCode>

Source§

impl EndpointDetails for RefreshEP

Source§

const METHOD: Method = http::Method::GET

Source§

const PATH: &'static str = ".ph/user/refresh"

Source§

type RequestType = NoPayload

Source§

type ResponseType = Result<RefreshResp, ErrorCode>

Source§

impl EndpointDetails for StateEP

Source§

const METHOD: Method = http::Method::GET

Source§

const PATH: &'static str = ".ph/user/state"

Source§

type RequestType = NoPayload

Source§

type ResponseType = Result<StateResp, ErrorCode>

Source§

impl EndpointDetails for pubhubs::api::phc::user::WelcomeEP

Source§

const METHOD: Method = http::Method::GET

Source§

const PATH: &'static str = ".ph/user/welcome"

Source§

type RequestType = NoPayload

Source§

type ResponseType = Result<WelcomeResp, ErrorCode>

Source§

impl EndpointDetails for HubPingEP

Source§

const METHOD: Method = http::Method::POST

Source§

const PATH: &'static str = ".ph/hub/ping"

Source§

type RequestType = TicketSigned<PingReq>

Source§

type ResponseType = Result<PingResp, ErrorCode>

Source§

impl EndpointDetails for DiscoveryInfo

Source§

const METHOD: Method = http::Method::GET

Source§

const PATH: &'static str = ".ph/discovery/info"

Source§

type RequestType = NoPayload

Source§

type ResponseType = Result<DiscoveryInfoResp, ErrorCode>

Source§

impl EndpointDetails for DiscoveryRun

Source§

const METHOD: Method = http::Method::POST

Source§

const PATH: &'static str = ".ph/discovery/run"

Source§

type RequestType = NoPayload

Source§

type ResponseType = Result<DiscoveryRunResp, ErrorCode>

Source§

impl EndpointDetails for EhppEP

Source§

const METHOD: Method = http::Method::POST

Source§

const PATH: &'static str = ".ph/ehpp"

Source§

type RequestType = EhppReq

Source§

type ResponseType = Result<EhppResp, ErrorCode>