> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gcore.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Build a FastEdge HTTP application

> Build and deploy a FastEdge HTTP application from a WebAssembly handler written in Rust or JavaScript.

FastEdge HTTP applications respond to HTTP requests directly from the edge. The handler compiles to a WebAssembly binary and runs without servers or containers. Three language options are available — complete the toolchain setup first: [Rust (Modern HTTP)](/fastedge/getting-started/setup-rust-modern), [Rust (Legacy HTTP)](/fastedge/getting-started/setup-rust-legacy), or [JavaScript](/fastedge/getting-started/setup-javascript).

## Write a handler

Each language uses a different entry point convention. Choose the tab that matches the toolchain set up earlier.

**Modern Rust**

Replace `src/lib.rs` with:

```rust theme={null}
use wstd::http::body::Body;
use wstd::http::{Request, Response};

#[wstd::http_server]
async fn main(request: Request<Body>) -> anyhow::Result<Response<Body>> {
    let url = request.uri().to_string();
    Ok(Response::builder()
        .status(200)
        .header("content-type", "text/plain;charset=UTF-8")
        .body(Body::from(format!("Request received: {url}")))?)
}
```

**Legacy Rust**

Replace `src/lib.rs` with:

```rust theme={null}
use fastedge::body::Body;
use fastedge::http::{Request, Response, StatusCode, Error};

#[fastedge::http]
fn main(request: Request<Body>) -> Result<Response<Body>, Error> {
    let url = request.uri().to_string();
    Response::builder()
        .status(StatusCode::OK)
        .header("content-type", "text/plain;charset=UTF-8")
        .body(Body::from(format!("Request received: {url}")))
}
```

**JavaScript**

Create `src/index.js`:

```js theme={null}
addEventListener('fetch', (event) => {
  const url = event.request.url;
  event.respondWith(new Response(`Request received: ${url}`));
});
```

## Build

Compile the handler to a WebAssembly binary. The first build downloads dependencies and takes one to two minutes.

**Modern Rust**

```sh theme={null}
cargo build --release --target wasm32-wasip2
```

The binary is at `./target/wasm32-wasip2/release/hello_world.wasm`.

**Legacy Rust**

```sh theme={null}
cargo build --release --target wasm32-wasip1
```

The binary is at `./target/wasm32-wasip1/release/hello_world.wasm`.

**JavaScript**

```sh theme={null}
npx fastedge-build --input src/index.js --output wasm/app.wasm
```

The binary is at `./wasm/app.wasm`.

## Deploy
