Skip to main content

Module http

Module http 

Source
Expand description

A minimal static file server, so serving the example needs nothing installed.

Built on hyper’s HTTP/1 server, with async-io as the reactor and async-executor as the runtime: hyper parses and encodes the protocol, the server only maps a request to a file. WebGPU requires a secure context, which http://localhost is, so the listener binds to loopback only.

Re-exportsΒ§

use std::path::Path; πŸ”’
use std::path::PathBuf; πŸ”’
use async_executor::Executor; πŸ”’
use async_io::Async; πŸ”’
use futures_lite::future; πŸ”’
use http_body_util::Full; πŸ”’
use hyper::body::Bytes; πŸ”’
use hyper::body::Incoming; πŸ”’
use hyper::server::conn::http1; πŸ”’
use hyper::service::service_fn; πŸ”’
use hyper::Request; πŸ”’
use hyper::Response; πŸ”’
use hyper::StatusCode; πŸ”’
use smol_hyper::rt::FuturesIo; πŸ”’
use smol_hyper::rt::SmolTimer; πŸ”’

FunctionsΒ§

answer πŸ”’
The response for one request.
bind πŸ”’
Bind to loopback at preferred_port or, if taken, the ports after it.
mime πŸ”’
The response Content-Type for path, by extension.
plain πŸ”’
A text/plain response, for the statuses that carry no file.
resolve πŸ”’
The file target asks for, or None for a request to refuse.
serve
Serve dir until stopped.
serve_connection πŸ”’
Answer every request on one connection.
serve_listener πŸ”’
Serve dir on an already-bound listener until stopped.