#apache #module #html

apache-rs

Rust FFI for creating Apache httpd modules

5 releases

0.0.4 Apr 7, 2024
0.0.3 Apr 7, 2024
0.0.2 May 12, 2022
0.0.1 Nov 20, 2021
0.0.0 Nov 20, 2021

#14 in #apache

Download history 3/week @ 2024-02-13 38/week @ 2024-02-20 4/week @ 2024-03-12 1/week @ 2024-03-26 232/week @ 2024-04-02 45/week @ 2024-04-09

278 downloads per month

Custom license

7KB
60 lines

apache-rs

Rust FFI for creating Apache httpd modules.

There is a bundled example implementing mod_example from the Apache httpd documentation: https://httpd.apache.org/docs/2.4/developer/modguide.html.

Setup

bindgen

https://rust-lang.github.io/rust-bindgen/requirements.html

  • Install system packages
sudo apt install llvm-dev libclang-dev clang

Apache httpd

  • Install system packages
sudo apt install apache2-dev libapr1-dev

Build

FFI

  • Build project
cargo build
cargo test --lib

Apache httpd module

  • Build Apache httpd module mod_example
cd examples/mod_example/
cargo build

Test

Locally

  • Build and install modules
cd examples/mod_example/
cargo build
sudo apxs -i -a -n example ./target/debug/libmod_example.so
cd examples/mod_sum/
cargo build
sudo apxs -i -a -n sum ./target/debug/libmod_sum.so
  • Add module configurations
sudo tee /etc/apache2/mods-available/example.conf > /dev/null <<EOT
<IfModule example_module>
    <Location "/example">
        SetHandler example-handler
    </Location>
</IfModule>
EOT
sudo a2enmod example
sudo tee /etc/apache2/mods-available/sum.conf > /dev/null <<EOT
<IfModule sum_module>
    AddHandler sum-handler .sum
</IfModule>
EOT
sudo a2enmod sum
  • Restart Apache httpd to load configuration
sudo systemctl restart apache2

No runtime deps

~0–1.8MB
~36K SLoC