oneitfarm-interface-httpserver 0.7.1

interface for actors to receive http requests (oneitfarm:httpserver)
Documentation

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()
        })
    }
}