[][src]Module embly::http

Tools for running http embly functions

Use the http module to run functions that expect to recieve an http response body and return an http response.

use embly::http::{run, Body, Request, ResponseWriter};
use std::io::Write;
use failure::Error;

fn execute(_req: Request<Body>, w: &mut ResponseWriter) -> Result<(), Error> {
    w.write("hello world\n".as_bytes())?;
    w.status("200")?;
    w.header("Content-Length", "12")?;
    w.header("Content-Type", "text/plain")?;
    Ok(())
}

fn main() -> Result<(), Error> {
    run(execute)
}

Structs

Body

An http body

Request

Represents an HTTP request.

Response

Represents an HTTP response

ResponseWriter

An http response writer. Used to write an http response, can either be used to write a complete response, or stream a response

Traits

Flusher

flusher

Functions

run

Run an http handler Function