Skip to main content

Crate fastcgi

Crate fastcgi 

Available on crate feature fastcgi only.
Expand description

FastCGI support for Rama.

§FastCGI

FastCGI is a binary protocol for interfacing interactive programs with a web server. It is a successor to CGI that avoids the overhead of spawning a new process for every request by keeping the application process alive and reusing it across many requests over a persistent connection.

The full specification is embedded in this crate at specifications/fastcgi_spec.txt.

§Server

Use FastCgiServer to accept FastCGI connections (typically from nginx or Apache acting as the web server front-end). It handles the protocol framing and dispatches each assembled request to your inner rama_core::Service.

The inner service receives a FastCgiRequest containing the CGI environment variables (params) and the request body (stdin), and must return a FastCgiResponse whose stdout bytes are sent back as the CGI response.

§Client

Use FastCgiClient to connect to a FastCGI backend application (e.g. PHP-FPM). It sends a FastCgiClientRequest (params + stdin) and returns a FastCgiClientResponse containing the raw stdout bytes from the application.

This is the piece a reverse proxy uses: it accepts HTTP, constructs CGI environment variables, and calls the FastCGI backend via the client.

§Protocol building blocks

The proto module exposes all protocol types and codec primitives if you need lower-level control:

§Rama

Crate used by the end-user rama crate and rama crate authors alike.

Learn more about rama:

Modules§

body
Streaming body type for FastCGI requests and responses.
client
FastCGI client implementation for Rama.
httphttp
HTTP adaptive layers for FastCGI.
proto
Implementation of the FastCGI Protocol.
server
FastCGI server implementation for Rama.

Structs§

ClientError
Error returned by FastCGI client framing operations.
ClientOptions
Configuration for FastCgiClient and send_on.
FastCgiBody
A streaming body for FastCGI requests and responses.
FastCgiClient
FastCGI client that wraps an inner connector service.
FastCgiClientRequest
A FastCGI client request to send to a backend application server.
FastCgiClientResponse
The raw bytes received from a FastCGI application.
FastCgiHttpClient
HTTP-to-FastCGI client.
FastCgiHttpClientConnector
A connector that translates HTTP requests into FastCGI connections.
FastCgiHttpEnv
Per-request override of selected CGI environment variables.
FastCgiHttpService
A FastCGI application service that wraps an inner HTTP service.
FastCgiRequest
A complete FastCGI request received from a web server.
FastCgiResponse
A FastCGI response to be sent back to the web server.
FastCgiServer
FastCGI server that accepts connections and dispatches requests to an inner service.
FastCgiTcpConnector
Open a TCP connection to a FastCGI backend (typically php-fpm at 127.0.0.1:9000).
FastCgiUnixConnector
Open a Unix-socket connection to a FastCGI backend (typically php-fpm at e.g. /run/php/php8.3-fpm.sock).
ServerOptions
Configuration for FastCgiServer.