mod_swift Documentation

mod_swift allows you to write native modules for the Apache Web Server in the Swift 3 programming language. That is without any proxies, interpreters or other hacks - fully integrated, compiled Apache modules that can do anything a C module could do.

Server Side Swift the right way.

What is an Apache module?

Apache is a highly modular and efficient server framework. The httpd daemon itself is quite tiny and pretty much all webserver functionality is actually implemented in the form of modules. Be it thread handling, access control, mime detection or content negotation - all of that is implemented as modules. And can be replaced by own modules!

The Apache core modules are written in portable C. Some modules are built right into the server, but most are loaded as dynamic libraries. Which ones is specified by the user in the configuration file, for example:

LoadModule authz_core_module /usr/libexec/apache2/
LoadModule mime_module       /usr/libexec/apache2/

Now with mod_swift you can write such modules using the Swift programming language. Enter:

LoadSwiftModule ApacheMain /usr/libexec/apache2/

This is a little different to something like mod_php which enables Apache to directly interpret PHP scripts. mod_php itself is C software and a single module. Since Swift compiles down to regular executable binaries, and because Swift has excellent C integration, you can write arbitrary modules with mod_swift which behave just like the regular C modules.