pub struct Context<D> { /* private fields */ }Expand description
What every callback receives: the application’s data, the canonical origin, and the request, if there is one. Cheap to clone.
Implementations§
Source§impl<D: Clone + Send + Sync + 'static> Context<D>
impl<D: Clone + Send + Sync + 'static> Context<D>
Sourcepub fn actor_uri(&self, kind: &str, identifier: &str) -> Result<Url, UriError>
pub fn actor_uri(&self, kind: &str, identifier: &str) -> Result<Url, UriError>
The URI of the actor of kind with identifier.
§Errors
When no actor dispatcher is of kind, or identifier is empty for a
template that needs one.
Sourcepub fn key_id(&self, kind: &str, identifier: &str) -> Result<Url, UriError>
pub fn key_id(&self, kind: &str, identifier: &str) -> Result<Url, UriError>
The ID of the key the actor of kind with identifier signs with;
see Uris::key_id.
§Errors
Sourcepub fn object_uri(
&self,
kind: &str,
values: &[(&str, &str)],
) -> Result<Url, UriError>
pub fn object_uri( &self, kind: &str, values: &[(&str, &str)], ) -> Result<Url, UriError>
The URI of the object of kind with values.
§Errors
When no object dispatcher is of kind, or values do not fill its
template.
Sourcepub fn collection_uri(
&self,
kind: &str,
identifier: &str,
) -> Result<Url, UriError>
pub fn collection_uri( &self, kind: &str, identifier: &str, ) -> Result<Url, UriError>
The URI of the collection kind of what identifier names.
§Errors
As Context::actor_uri, for collections.
Sourcepub fn inbox_uri(&self, kind: &str, identifier: &str) -> Result<Url, UriError>
pub fn inbox_uri(&self, kind: &str, identifier: &str) -> Result<Url, UriError>
The URI of the inbox of the actor of kind with identifier.
§Errors
As Context::actor_uri, for inboxes.
Sourcepub fn is_our_host(&self, host: &str) -> bool
pub fn is_our_host(&self, host: &str) -> bool
Whether host, with its port if it has one, is the canonical
origin’s or one of its aliases.
Sourcepub fn parse_uri(&self, iri: &str) -> Option<Route>
pub fn parse_uri(&self, iri: &str) -> Option<Route>
What iri is, if it is ours: on the canonical origin or an alias, and
matching a registered template.
Sourcepub fn parse_actor(&self, kind: &str, iri: &str) -> Option<String>
pub fn parse_actor(&self, kind: &str, iri: &str) -> Option<String>
The identifier of the actor of kind that iri is, if it is one of
ours: what a listener checks a Follow’s object against.
Sourcepub fn parse_object(&self, kind: &str, iri: &str) -> Option<Values>
pub fn parse_object(&self, kind: &str, iri: &str) -> Option<Values>
The values of the object of kind that iri is, if it is one of
ours: what a listener checks an inReplyTo or a Like’s object
against.
Sourcepub async fn actor_keys(
&self,
actor: &ActorRef,
) -> Result<Vec<PublicKey>, Error>
pub async fn actor_keys( &self, actor: &ActorRef, ) -> Result<Vec<PublicKey>, Error>
The public keys actor publishes, from the key-pairs dispatcher; none
when there is no such dispatcher.
§Errors
What the dispatcher returns.
Sourcepub async fn signer(&self) -> Option<Url>
pub async fn signer(&self) -> Option<Url>
The actor who signed the request, verified: the signature is sound,
made for this host and recently, and made with a key its actor
publishes. None when the request is unsigned, the signature fails,
there is no request, or signed fetches are not configured. Verified
once per request, however often it is asked.
Sourcepub async fn signing(&self) -> Signing
pub async fn signing(&self) -> Signing
How the request was signed: not at all, by an actor whose signature
verifies, with a key on a server Builder::blocked refuses, or with
a signature that does not hold. Verified once per request, however
often it is asked, and as Context::signer verifies it.
Sourcepub fn query(&self) -> Option<&str>
pub fn query(&self) -> Option<&str>
The query of the request, if there is a request and it has one: for a dispatcher that reads parameters of its own, such as how a collection it writes itself is paged.
Sourcepub fn query_value(&self, name: &str) -> Option<String>
pub fn query_value(&self, name: &str) -> Option<String>
The value of the query parameter name, decoded, if the request has
it: the first, when it has it more than once.
Sourcepub fn request_header(&self, name: &str) -> Option<String>
pub fn request_header(&self, name: &str) -> Option<String>
The value of the request’s header name, if it has one and it is
text.
Sourcepub fn set_response_header(&self, name: &str, value: Option<&str>)
pub fn set_response_header(&self, name: &str, value: Option<&str>)
Send value as the response’s header name, or no such header
when it is None, in place of what Ojak would send: for a
dispatcher or guard saying how the response may be cached, such as
its Cache-Control and the request headers it Varys on. It
applies to whatever the request is answered with, a refusal or a 404
included. A name or value that is no header is ignored.