Building websites in Swift.

The idea behind Swiftfire is that we wanted to build websites around HTML/CSS and Swift at the server side.

The reason is twofold:

  1. First and foremost is that we like Swift … a lot!
  2. Second is that we became increasingly frustrated by the complexity of the webserver environment and the tools needed to create and maintain a website.

Swift is a compiled language. In contrast to some other languages (like PHP) Swift is compiled and then deployed. This means that when Swift is used to create websites, the website is in fact an application!

It’s an application !

That application is build around Swiftfire. Swiftfire calls out to a series of services and functions that together implement the website (domain). While there are default services and functions, it is easy to implement additional services and functions by the website developper. Over time it is expected that Swiftfire will ship with enough services and functions such that most websites can be build without adding services and/or functions.

Note: The Swiftfire core does not care about the type of services, it can just as easily be used to implement a mailserver or ftp client as a webserver. By default Swiftfire ships with a stack of services that implement a webserver.


Services are written around the HTTP request. Mostly this means that services take some kind of action based on the URL that is received. However they are not limited to the URL and have access to the entire HTTP request, both the header and the body.

An example service is the blacklisting of clients based on their IP address. (A default service)

Services are written in Swift.


Functions can be activated from any file that contains the four magic characters “.sf.” in its filename.

When these characters are found, Swiftfire will scan the file for occurrences of “functions” and replace these functions by their outputs.

The function itself is a sequence of characters that is (partly) defined by the name of the functions.


Assume that this line occurs in “index.sf.html”:

<p>This page has been accessed .nofPageHits() times</p>

The “.nofPageHits()” is a (standard) function that returns the number of times a page is accessed. This line will then be transferred to the client as:

<p>This page has been accessed 64931 times</p>

Functions are also written in Swift.

Oh, and btw, Swiftfire will map requests for the index to index.sf.html when necessary.

Not for everyone

Swiftfire is not for everyone. Large corporations or big sites that must be run by teams of admins and contributors are not at the focus of Swiftfire.

Swiftfire is intended for the personal sphere. For your website(s). That are hosted on your own server.


Webservers are usually applications that run without a graphical user interface (GUI). I.e. you don’t see any windows when they run. They are invisible, except for their effect. Swiftfire is no exception, it too runs without a GUI.

However Swiftfire comes with a site for administration purposes. This site must be referenced during the initial deployment of Swiftfire, along with the details of the admin account.