Skip to content

An example module for Ferron, demonstrating how to create a custom HTTP handler module with Ferron.

License

Notifications You must be signed in to change notification settings

ferronweb/ferron-module-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ferron example module

This is an example module for Ferron, demonstrating how to create a custom HTTP handler module with Ferron.

Notes

This module responds with "Hello World!" for "/hello" request paths.

Additional KDL configuration directives

Directives

  • example_handler [enable_example_handler: bool]
    • This directive specifies whenever an example handler is enabled. This handler responds with "Hello World" for "/hello" request paths. Default: example_handler #false

Configuration example:

dev.example.com {
    // Enable example handler for testing
    example_handler

    // Enhanced logging for development
    log "/var/log/ferron/dev.access.log"
    error_log "/var/log/ferron/dev.error.log"

    // Custom test endpoints
    status 200 url="/test" body="Test endpoint working"
    status 500 url="/test-error" body="Simulated error"
}

Compiling Ferron with this module

To compile Ferron with this module, first clone the Ferron repository:

git clone https://github.com/ferronweb/ferron.git -b develop-2.x
cd ferron

Then, copy the ferron-build.yaml file to ferron-build-override.yaml:

cp ferron-build.yaml ferron-build-override.yaml

After that, add the following line to the ferron-build-override.yaml file:

modules:
  # Other modules...
  - git: https://github.com/ferronweb/ferron-module-example.git
    crate: ferron-module-example
    loader: ExampleModuleLoader

It's suggested to define this module between the module with ReverseProxyModuleLoader and FcgiModuleLoader.

After modifying the ferron-build-override.yaml file, you can compile Ferron with this module by running the following command:

make build

Or if you're on Windows:

powershell -ExecutionPolicy Bypass .\build.ps1 Build

You can then package it in a ZIP archive using the following command:

make package

Or if you're on Windows:

powershell -ExecutionPolicy Bypass .\build.ps1 Package

The ZIP archive will be created in the dist directory, and can be installed using Ferron installer.

About

An example module for Ferron, demonstrating how to create a custom HTTP handler module with Ferron.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published