pub struct ServerActions<T: Caller> {
pub caller: T,
}
Expand description
Interface for services which serve http
The http-server
service uses this interface to call into other services to respond
to http requests.
To implement this interface, add a serveSys action to your service.
Fields§
§caller: T
Implementations§
Source§impl<T: Caller> ServerActions<T>
impl<T: Caller> ServerActions<T>
Sourcepub fn serveSys(&self, request: HttpRequest) -> T::ReturnType<Option<HttpReply>>
pub fn serveSys(&self, request: HttpRequest) -> T::ReturnType<Option<HttpReply>>
Handle HTTP requests
Define this action in your service to handle HTTP requests. You’ll also need to
register your service by calling the registerServer action in the http-server
service.
serveSys
can do any of the following:
- Return
None
to signal not found. psinode produces a 404 response in this case. - Abort. psinode produces a 500 response with the service’s abort message.
- Return a psibase::HttpReply. psinode produces a 200 response with the body and contentType returned.
- Call other services.
- Call
http-server::sendReply
. Explicitly sends a response. - Call
http-server::deferReply
. No response will be produced untilhttp-server::sendReply
is called.
A service runs in RPC mode while serving an HTTP request. This mode prevents database writes, but allows database reads, including reading data and events which are normally not available to services; see psibase::DbId.
Trait Implementations§
Source§impl<T: Clone + Caller> Clone for ServerActions<T>
impl<T: Clone + Caller> Clone for ServerActions<T>
Source§fn clone(&self) -> ServerActions<T>
fn clone(&self) -> ServerActions<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T: Caller> From<T> for ServerActions<T>
impl<T: Caller> From<T> for ServerActions<T>
Source§impl<T: Caller> ToActionsSchema for ServerActions<T>
impl<T: Caller> ToActionsSchema for ServerActions<T>
fn to_schema( builder: &mut SchemaBuilder, ) -> IndexMap<MethodString, FunctionType>
Auto Trait Implementations§
impl<T> Freeze for ServerActions<T>where
T: Freeze,
impl<T> RefUnwindSafe for ServerActions<T>where
T: RefUnwindSafe,
impl<T> Send for ServerActions<T>where
T: Send,
impl<T> Sync for ServerActions<T>where
T: Sync,
impl<T> Unpin for ServerActions<T>where
T: Unpin,
impl<T> UnwindSafe for ServerActions<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more