{"id":33933626,"url":"https://github.com/fastly/esi","last_synced_at":"2025-12-30T04:08:06.986Z","repository":{"id":36999348,"uuid":"489384929","full_name":"fastly/esi","owner":"fastly","description":"A streaming Edge Side Includes parser and executor designed for Fastly Compute.","archived":false,"fork":true,"pushed_at":"2025-11-13T17:34:05.000Z","size":654,"stargazers_count":11,"open_issues_count":13,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-11-17T18:28:49.573Z","etag":null,"topics":["compute-library","esi","fastly-oss-tier1"],"latest_commit_sha":null,"homepage":"https://docs.rs/esi","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"kailan/esi","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fastly.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-05-06T14:27:49.000Z","updated_at":"2025-10-27T16:15:42.000Z","dependencies_parsed_at":"2023-02-16T18:32:06.102Z","dependency_job_id":"eff7e665-731f-4ee2-95d5-1673e5953d13","html_url":"https://github.com/fastly/esi","commit_stats":{"total_commits":73,"total_committers":4,"mean_commits":18.25,"dds":0.4931506849315068,"last_synced_commit":"df0ab8b5c3296caf1507e32c50f44c678af93bad"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/fastly/esi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastly%2Fesi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastly%2Fesi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastly%2Fesi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastly%2Fesi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fastly","download_url":"https://codeload.github.com/fastly/esi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastly%2Fesi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27599194,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-08T02:00:07.111Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compute-library","esi","fastly-oss-tier1"],"created_at":"2025-12-12T13:06:13.816Z","updated_at":"2025-12-12T13:06:14.590Z","avatar_url":"https://github.com/fastly.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ESI for Fastly\n\nThis crate provides a streaming Edge Side Includes parser and executor designed for Fastly Compute.\n\nThe implementation is a subset of the [ESI Language Specification 1.0](https://www.w3.org/TR/esi-lang/) supporting the following tags:\n\n- `\u003cesi:include\u003e` (+ `alt`, `onerror=\"continue\"`)\n- `\u003cesi:try\u003e` | `\u003cesi:attempt\u003e` | `\u003cesi:except\u003e`\n- `\u003cesi:vars\u003e` | `\u003cesi:assign\u003e`\n- `\u003cesi:choose\u003e` | `\u003cesi:when\u003e` | `\u003cesi:otherwise\u003e`\n- `\u003cesi:comment\u003e`\n- `\u003cesi:remove\u003e`\n\nOther tags will be ignored and served to the client as-is.\n\nThis implementation also includes an expression interpreter and library of functions that can be used. Current functions include:\n\n- `$lower(string)`\n- `$html_encode(string)`\n- `$replace(haystack, needle, replacement [, count])`\n\n## Example Usage\n\n```rust,no_run\nuse fastly::{http::StatusCode, mime, Error, Request, Response};\n\nfn main() {\n    if let Err(err) = handle_request(Request::from_client()) {\n        println!(\"returning error response\");\n\n        Response::from_status(StatusCode::INTERNAL_SERVER_ERROR)\n            .with_body(err.to_string())\n            .send_to_client();\n    }\n}\n\nfn handle_request(req: Request) -\u003e Result\u003c(), Error\u003e {\n    // Fetch ESI document from backend.\n    let mut beresp = req.clone_without_body().send(\"origin_0\")?;\n\n    // If the response is HTML, we can parse it for ESI tags.\n    if beresp\n        .get_content_type()\n        .map(|c| c.subtype() == mime::HTML)\n        .unwrap_or(false)\n    {\n        let processor = esi::Processor::new(\n            // The original client request.\n            Some(req),\n            // Use the default ESI configuration.\n            esi::Configuration::default()\n        );\n\n        processor.process_response(\n            // The ESI source document. Note that the body will be consumed.\n            \u0026mut beresp,\n            // Optionally provide a template for the client response.\n            Some(Response::from_status(StatusCode::OK).with_content_type(mime::TEXT_HTML)),\n            // Provide logic for sending fragment requests, otherwise the hostname\n            // of the request URL will be used as the backend name.\n            Some(\u0026|req| {\n                println!(\"Sending request {} {}\", req.get_method(), req.get_path());\n                Ok(req.with_ttl(120).send_async(\"mock-s3\")?.into())\n            }),\n            // Optionally provide a method to process fragment responses before they\n            // are streamed to the client.\n            Some(\u0026|req, resp| {\n                println!(\n                    \"Received response for {} {}\",\n                    req.get_method(),\n                    req.get_path()\n                );\n                Ok(resp)\n            }),\n        )?;\n    } else {\n        // Otherwise, we can just return the response.\n        beresp.send_to_client();\n    }\n\n    Ok(())\n}\n```\n\nSee example applications in the [`examples`](./examples) subdirectory or read the hosted documentation at [docs.rs/esi](https://docs.rs/esi). Due to the fact that this processor streams fragments to the client as soon as they are available, it is not possible to return a relevant status code for later errors once we have started streaming the response to the client. For this reason, it is recommended that you refer to the [`esi_example_advanced_error_handling`](./examples/esi_example_advanced_error_handling) application, which allows you to handle errors gracefully by maintaining ownership of the output stream.\n\n## Testing\n\nIn order to run the test suite for the packages in this repository, [`viceroy`](https://github.com/fastly/Viceroy) must be available in your PATH. You can install the latest version of `viceroy` by running the following command:\n\n```sh\ncargo install viceroy\n```\n\n## License\n\nThe source and documentation for this project are released under the [MIT License](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastly%2Fesi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffastly%2Fesi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastly%2Fesi/lists"}