Crate kvarn

Source
Expand description

An extensible and efficient forward-thinking web server for the future.

Kvarn is a rethought web server tailored for the current needs from web application developers.

It handles several things for you, including

  • Content-Type
  • Compression of body
  • Correct and performant HTTP/1 and HTTP/2
  • Common API across HTTP/1 and HTTP/2
  • Easy integration with HTTP/2 push promises
  • Five types of extensions, all backed with intuitive macros
  • Optional encryption with rustls
  • Several checks for illegal requests
  • cache-control and kvarn-cache-control header limits server cache lifetimes

§Getting started

To get started, configure a RunConfig. See the example at RunConfig::execute on how to get a simple web server running.

A battle-tested reference implementation can be found at GitHub. It powers my two websites with minimal resource requirements.

§Future plans

See the README @ GitHub and kvarn.org.

Re-exports§

pub use error::default as default_error;
pub use error::default_response as default_error_response;
pub use extensions::Extensions;
pub use extensions::Id;
pub use read::file as read_file;
pub use read::file_cached as read_file_cached;

Modules§

application
Abstractions for the application layer, providing a common interface for all HTTP versions supported.
comprash
Compress and cache.
cors
CORS implementation for Kvarn.
csp
CSP implementation for Kvarn.
ctlhandover
Control the Kvarn server from the outside.
encryption
Encryption for incoming and outgoing traffic, implemented through streams.
error
Utility functions to generate error responses.
extensions
Here, all extensions code is housed.
host
Handling of multiple Hosts on one instance of Kvarn.
limiting
Limits traffic from a IP address to partially mitigate attacks.
prelude
The Kvarn Prelude
read
Utilities for reading files with or without a FileCache.
shutdown
Graceful shutdown for Kvarn.
vary
Vary header handling in Kvarn.
websocketwebsocket
Easy and fast WebSockets for Kvarn.

Macros§

box_fut
Create a pinned future, compatible with crate::RetFut.
extension
The ultimate extension-creation macro.
package
Construct a Package extension like you write closures.
pluginhandover
Create a Plugin.
post
Construct a Post extension like you write closures.
prepare
Construct a Prepare extension like you write closures.
present
Construct a Present extension like you write closures.
prime
Construct a Prime extension like you write closures.
response_pipe_fut
Creates a super::ResponsePipeFuture.
run_config
Creates a RunConfig from PortDescriptors. This allows you to configure the RunConfig and then RunConfig::execute the server.

Structs§

CacheReply
The returned data from handle_cache.
FatResponse
A Response returned by handle_request().
PortDescriptor
Describes port, certificate, and host data for a single port to bind.
RunConfig
Configuration for Self::execute. This mainly consists of an array of PortDescriptors.

Enums§

BindIpVersion
Which version of the Internet Protocol to bind to.
Incoming
An incoming connection, before it’s wrapped with HTTP.
SendKind
How to send data to the client.

Functions§

handle_cache
Will handle a single request, check the cache, process if needed, and caches it. This is where the response is sent.
handle_connection
Handles a single connection. This includes encrypting it, extracting the HTTP header information, optionally (HTTP/2 & HTTP/3) decompressing them, and passing the request to handle_cache(). It will also recognize which host should handle the connection.
handle_request
Handles a single request and returns response with cache and compress preference.
spawn
Spawn a task.

Type Aliases§

FatRequest
The Request used within Kvarn.