caddyfile-rs 0.1.0

Caddyfile lexer, parser, formatter, and builder for Caddy web server configuration files
Documentation
  • Coverage
  • 66.67%
    76 out of 114 items documented1 out of 45 items with examples
  • Size
  • Source code size: 172.56 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 7.93 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 17s Average build duration of successful builds.
  • all releases: 17s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • LeakIX/caddyfile-rs
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • dannywillems

caddyfile-rs

A Rust library for parsing, formatting, and building Caddyfile configuration files for the Caddy web server.

Features

  • 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

CLI

Install the caddyfile command-line tool:

cargo install --git https://github.com/LeakIX/caddyfile-rs

Validate

caddyfile validate Caddyfile

Format

caddyfile fmt Caddyfile

Check formatting

caddyfile check Caddyfile

GitHub Actions

Add 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 Caddyfile

Documentation

See the full API reference on docs.rs.

License

MIT