---
title: "HTTP Server | Cosmonic"
description: "Deploy a multi-endpoint HTTP server written in Go as a WebAssembly component on Cosmonic Control."
canonical: "https://cosmonic.com/docs/template-catalog/http-server/"
---

# HTTP Server

A simple HTTP server with multiple endpoints, implemented as a Wasm component and packaged for Cosmonic Control.

## Deploy with Helm

```shell
helm install http-server --version 0.2.0 oci://ghcr.io/cosmonic-labs/charts/http-trigger -f https://raw.githubusercontent.com/cosmonic-labs/control-demos/refs/heads/main/http-server/values.http-trigger.yaml
```

**Repository**: [`cosmonic-labs/control-demos/http-server`](https://github.com/cosmonic-labs/control-demos/tree/main/http-server)  
**Languages**: Go  
**Interfaces**: `wasi/http`

## Running on Kubernetes

You will need a local Kubernetes environment with Cosmonic Control installed according to the [Get Started](https://cosmonic.com/docs/install-cosmonic-control/) guide.

Connect to the component at `http://http-server.localhost.cosmonic.sh`:

```shell
curl http://http-server.localhost.cosmonic.sh
```

### Send a request

You can send a request to the following endpoints:

**GET /**

Returns a list of available endpoints and their descriptions.

```shell
curl http://http-server.localhost.cosmonic.sh/
```

```text
  /error - return a 500 error
  /form - echo the fields of a POST request
  /headers - echo your user agent back as a server side header
  /post - echo the body of a POST request
```

**GET /error**

Returns a 500 Internal Server Error.

```shell
curl -v http://http-server.localhost.cosmonic.sh/error
```

```text
< HTTP/1.1 500 Internal Server Error
< content-type: text/plain; charset=utf-8
<
Something went wrong
```

**GET /headers**

Returns your User-Agent in the response headers.

```shell
curl -v http://http-server.localhost.cosmonic.sh/headers
```

```text
< HTTP/1.1 200 OK
< x-your-user-agent: curl/8.7.1
<
Check headers!
```

**POST /form**

Echoes back form data from a POST request.

```shell
curl -X POST -d "field1=value1&field2=value2" http://http-server.localhost.cosmonic.sh/form
```

```text
field2: value2
field1: value1
```

**POST /post**

Echoes back the entire body of a POST request.

```shell
curl -X POST -d "Hello World" http://http-server.localhost.cosmonic.sh/post
```

```text
Hello World
```

## Development

Development requirements:

- [`tinygo`](https://tinygo.org/getting-started/install/) for compiling Go
- [`wasm-tools`](https://github.com/bytecodealliance/wasm-tools#installation) for Go bindings
- [`wash`](https://github.com/wasmCloud/wasmcloud) **v2.0.4** for building the component

Clone the [`cosmonic-labs/control-demos`](https://github.com/cosmonic-labs/control-demos) repository:

```shell
git clone https://github.com/cosmonic-labs/control-demos.git
```

```shell
cd control-demos/http-server
```

Start the development loop:

```shell
wash dev
```

When using `wash dev`, the HTTP Server is accessible at localhost:8000. View the code and make changes in `main.go`.

You can cancel the `wash dev` process with `Ctrl-C`.

### Build the Wasm Binary

Compile the component:

```shell
wash build
```

The `.wasm` binary will output to `./build`.

## Learn More

- See the wasmCloud Developer Guide for instructions on [pushing your Wasm component to an OCI registry](https://wasmcloud.com/docs/wash/developer-guide/).

- To learn how to extend this example with additional capabilities, see the [Adding Capabilities](https://wasmcloud.com/docs/tour/adding-capabilities?lang=rust) section of the wasmCloud documentation.
- For more on building components in Go, see the [Component Developer Guide](https://wasmcloud.com/docs/developer/languages/go/components/) in the wasmCloud documentation.

Last updated on **Nov 10, 2026** by **Liam Randall**
