Skip to main content

Crate tako

Crate tako 

Source
Expand description

A multi-transport Rust framework for modern network services.

Tako is built for services that go beyond plain HTTP. It gives you one cohesive model for routing, extraction, middleware, streaming, observability, and graceful shutdown across several protocols and transport layers.

§Why Tako

  • One application can expose HTTP APIs, realtime channels, and raw transports without switching frameworks.
  • The same ergonomic handler and extractor model applies across higher-level web routes and lower-level network services.
  • Platform primitives such as middleware, queues, signals, streaming, metrics, and file serving are part of the framework story.
  • You can stay on the default tokio runtime or opt into compio where it is a better fit.

§High-level features

  • Multi-transport support: HTTP/1.1, HTTP/2, HTTP/3, WebSocket, SSE, gRPC, TCP, UDP, Unix sockets, PROXY protocol, and WebTransport
  • Dual runtime support with tokio by default and optional compio
  • Macro-free routing with dynamic path params and TSR support
  • Type-safe handlers with extractor-based arguments
  • Simple Responder trait to return strings, tuples, or full responses
  • Middleware pipeline plus optional plugins for CORS, compression, rate limiting, and metrics
  • Streaming bodies, file serving, range requests, and SSE helpers
  • Built-in background queue and in-process signals for application workflows
  • Optional GraphQL support, GraphiQL UI, and OpenAPI integrations

§Runtime support

  • tokio is the default runtime and powers the standard server path
  • compio is available behind feature flags for teams that want an alternative async runtime model
  • hyper 1.x remains the core HTTP engine for the default runtime path

§Best fit

Tako is a strong fit when your service needs more than REST:

  • HTTP APIs plus WebSockets, SSE, gRPC, or QUIC-based transports
  • Realtime coordination with built-in signals and queue primitives
  • Protocol gateways, telemetry collectors, internal platforms, or edge-facing services

§Quickstart

use tako::{Method, router::Router, responder::Responder, types::Request};

async fn hello(_: Request) -> impl Responder { "Hello, World!" }

let mut router = Router::new();
router.route(Method::GET, "/", hello);

§Key concepts

  • router::Router manages routes, middleware and dispatch.

  • extractors parse request data (headers, params, JSON, forms, etc.).

  • responder::Responder converts return values into HTTP responses.

  • middleware composes cross-cutting concerns.

  • Static file serving (module static) and file_stream provide static and streaming file responses.

  • [ws] and sse enable real-time communication.

  • queue and signals provide built-in application coordination primitives.

  • plugins add CORS, compression, and rate limiting (feature: plugins).

  • graphql and graphiql add GraphQL support (feature: async-graphql / graphiql).

§Feature flags

  • client — outbound HTTP clients over TCP/TLS
  • compio — alternate runtime support
  • compio-tls / compio-ws — TLS and WebSocket support on compio
  • file-stream — file streaming utilities
  • http2 — enable ALPN h2 in TLS server
  • http3 — HTTP/3 over QUIC
  • jemalloc — use jemalloc as global allocator
  • multipart — multipart form-data extractors
  • plugins — CORS, compression, rate limiting
  • protobuf — protobuf extractors (prost)
  • simd — SIMD JSON extractor (simd-json)
  • signals — in-process pub/sub and RPC-style signaling
  • tls — TLS server (rustls)
  • tako-tracing — structured tracing subscriber
  • utoipa / vespera — OpenAPI integrations
  • webtransport — QUIC-based WebTransport sessions
  • zero-copy-extractors — zero-copy extraction helpers
  • zstd — Zstandard compression option within plugins::compression

Re-exports§

pub use responder::NOT_FOUND;
pub use server_compio::serve;compio
pub use server_compio::serve_with_shutdown;compio
pub use server_tls_compio::serve_tls;tls
pub use server_tls_compio::serve_tls_with_shutdown;tls

Modules§

body
HTTP request and response body handling utilities. HTTP request and response body handling utilities for efficient data processing.
config
Configuration loading from environment variables. Configuration loading from environment variables.
extractors
Request data extraction utilities for parsing query params, JSON, and more. HTTP request data extraction utilities and traits.
file_streamfile-stream
File streaming utilities for serving files. File streaming utilities for efficient HTTP file delivery.
graphiqlgraphiql
GraphiQL UI helpers. GraphiQL HTML responder and helper for Tako.
graphqlasync-graphql
GraphQL support (request extractors, responses, and subscriptions). Async-GraphQL integration for Tako: extractors, responses, and subscriptions.
grpcgrpc
gRPC support for unary RPCs with protobuf serialization. gRPC support for unary RPCs over HTTP/2.
header
HTTP header types
middleware
Middleware for processing requests and responses in a pipeline. Middleware system for request and response processing pipelines.
openapiutoipa or vespera
OpenAPI documentation generation integrations (utoipa, vespera). OpenAPI documentation generation integrations.
pluginsplugins
Plugin system for extending framework functionality. Plugin system for extending framework functionality with composable modules.
queue
In-memory background job queue with retry, delayed jobs, and dead letter support. In-memory background job queue with named queues, retry policies, and dead letter support.
redirect
Redirection utilities for handling HTTP redirects. Redirect response utilities for handlers.
responder
Response generation utilities and traits. Response generation utilities and trait implementations for HTTP responses.
router
Request routing and dispatch functionality. HTTP request routing and dispatch functionality.
server_compiocompio
Compio server implementation for efficient I/O operations.
server_tcp
Raw TCP server for handling arbitrary TCP connections. Raw TCP server for handling arbitrary TCP connections.
server_tls_compiocompio and tls
TLS-enabled HTTP server implementation for secure connections (compio runtime).
server_udp
UDP datagram server for handling raw UDP packets. UDP datagram server for handling raw UDP packets.
signalssignals
In-process signal arbiter for custom events. In-process signal arbiter and dispatch system.
sse
Server-Sent Events (SSE) support for real-time communication. Server-Sent Events (SSE) implementation for real-time data streaming.
state
Application state management and dependency injection. Global application state management and dependency injection (type-based).
static
Static file serving utilities. Static file serving utilities for web applications.
tracingtako-tracing
Distributed tracing integration for observability. Distributed tracing integration for observability and debugging.
types
Core type definitions used throughout the framework. Core type definitions and aliases used throughout the Tako framework.
ws_compiocompio-ws
WebSocket connection handling for compio runtime. WebSocket connection handling for compio runtime.
zero_copy_extractorszero-copy-extractors

Structs§

Bytes
A cheaply cloneable and sliceable chunk of contiguous memory.
Full
A body that consists of a single chunk.
Method
The Request Method (VERB)
StatusCode
An HTTP status code (status-code in RFC 9110 et al.).

Functions§

bind_with_port_fallbackcompio
Bind a TCP listener for addr, asking interactively to increment the port if it is already in use (compio version).