#capability #actor #api-bindings #capability-provider #oneitfarm

oneitfarm-interface-httpserver

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

2 releases

0.7.1 Oct 18, 2022
0.7.0 Oct 18, 2022

#27 in #capability-provider

Apache-2.0 and maybe LGPL-3.0-or-later

26KB
564 lines

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

Dependencies

~15–31MB
~491K SLoC