Crates.io | oneitfarm-interface-httpserver |
lib.rs | oneitfarm-interface-httpserver |
version | 0.7.1 |
source | src |
created_at | 2022-10-18 05:59:13.84162 |
updated_at | 2022-10-18 08:15:33.629984 |
description | interface for actors to receive http requests (oneitfarm:httpserver) |
homepage | |
repository | |
max_upload_size | |
id | 690674 |
size | 25,028 |
This is the interface for an HTTP Server capability with the contract ID oneitfarm:httpserver
This folder contains
oneitfarm:httpserver
Any Rust actor or capability provider using oneitfarm:httpserver
should rely upon this library. A capability provider implements the trait HttpServerReceiver
.
Implementing the HttpServer.HandleRequest
operation
use wasmbus_rpc::actor::prelude::*;
use oneitfarm_interface_httpserver::{HttpRequest, HttpResponse, HttpServer, HttpServerReceiver};
#[derive(Debug, Default, Actor, HealthResponder)]
#[services(Actor, HttpServer)]
struct HelloActor {}
#[async_trait]
impl HttpServer for HelloActor {
async fn handle_request(&self, _ctx: &Context, _req: &HttpRequest) -> RpcResult<HttpResponse> {
Ok(HttpResponse {
body: "Hello World".as_bytes().to_owned(),
..Default::default()
})
}
}