oneitfarm-interface-httpserver

Crates.iooneitfarm-interface-httpserver
lib.rsoneitfarm-interface-httpserver
version0.7.1
sourcesrc
created_at2022-10-18 05:59:13.84162
updated_at2022-10-18 08:15:33.629984
descriptioninterface for actors to receive http requests (oneitfarm:httpserver)
homepage
repository
max_upload_size
id690674
size25,028
ROVAST (rovast)

documentation

README

oneitfarm HTTP Server Interface

This is the interface for an HTTP Server capability with the contract ID oneitfarm:httpserver

This folder contains

  • Model definition for oneitfarm:httpserver
  • Generated documentation (in HTML)
  • Generated Rust library (in Rust)

Any Rust actor or capability provider using oneitfarm:httpserver should rely upon this library. A capability provider implements the trait HttpServerReceiver.

Example Usage (🦀 Rust)

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()
        })
    }
}
Commit count: 0

cargo fmt