A Rust library for parsing, formatting, and building Caddyfile configuration files for the Caddy web server.
- Lexer - tokenize Caddyfile source text with full span tracking
- Parser - parse tokens into a typed AST
- Formatter - pretty-print AST back to valid Caddyfile syntax
- Builder - programmatic API for constructing Caddyfiles
- Round-trip safe - parse then format produces identical output
- Zero dependencies beyond
thiserror
Install the caddyfile command-line tool:
cargo install --git https://github.com/LeakIX/caddyfile-rscaddyfile validate Caddyfilecaddyfile fmt Caddyfilecaddyfile check CaddyfileAdd a workflow to validate your Caddyfile on every push (see validate-caddyfile.yaml):
name: Validate Caddyfile
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
validate:
name: Validate Caddyfile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install caddyfile CLI
run: cargo install --git https://github.com/LeakIX/caddyfile-rs
- name: Validate Caddyfile
run: caddyfile validate Caddyfile
- name: Check formatting
run: caddyfile check CaddyfileSee the full API reference on leakix.github.io/caddyfile-rs.
MIT