Crate esi

source · []
Expand description

ESI for Fastly

This crate provides a streaming Edge Side Includes parser and executor designed for Fastly Compute@Edge.

The implementation is currently a subset of the ESI Language Specification 1.0, so only the esi:include tag is supported. Other tags will be ignored.

Usage Example

use esi::Processor;
use fastly::{http::StatusCode, mime, Error, Request, Response};

fn main() {
    if let Err(err) = handle_request(Request::from_client()) {
        println!("returning error response");


fn handle_request(req: Request) -> Result<(), Error> {
    // Fetch ESI document from backend.
    let beresp = req.clone_without_body().send("origin_0")?;

    // Construct an ESI processor with the default configuration.
    let config = esi::Configuration::default();
    let processor = Processor::new(config);

    // Execute the ESI document using the client request as context
    // and sending all requests to the backend `origin_1`.
    processor.execute_esi(req, beresp, &|req| {



This struct is used to configure optional behaviour within the ESI processor.

An instance of the ESI processor with a given configuration.


Representation of either XML data or a parsed ESI tag.

Describes an error encountered during ESI parsing or execution.

Representation of an ESI tag from a source response.


Parses the ESI document from the given reader and calls the callback closure upon each successfully parsed ESI tag.