Skip to main content

HTTP Server

The HTTP server capability allows your application component to handle HTTP requests. This enables serverless HTTP functions, RESTful HTTP APIs, serving static websites, or serve as an interaction point for any other application that communicates over HTTP. This capability is included as one of the open source wasmCloud interfaces and has the capability contract ID wasmcloud:httpserver.

Using this capability

This capability can be used in your project by adding a dependency on the wasmcloud-interface-httpserver crate, and by adding wasmcloud:httpserver to the capabilities section in your application's wasmcloud.toml file.

cargo add wasmcloud-interface-httpserver


capabilities = ["wasmcloud:httpserver"]



Example Usage

use wasmbus_rpc::actor::prelude::*;
use wasmcloud_interface_httpserver::{HttpRequest, HttpResponse, HttpServer, HttpServerReceiver};

#[derive(Debug, Default, Actor, HealthResponder)]
#[services(Actor, HttpServer)]
struct HelloActor {}

impl HttpServer for HelloActor {
    async fn handle_request(&self, _ctx: &Context, _req: &HttpRequest) -> RpcResult<HttpResponse> {
        HttpResponse::ok("Hello World")

Choosing an Implementation

On Cosmonic, your applications will only be able to receive HTTP requests through a wormhole that securely creates an HTTPS endpoint that can be forwarded to an individual application component. Because of this, the supported HTTP server implementation is Cosmonic's wormhole-aware HTTP server.