Building websites in Swift.

The idea behind Swiftfire is that we wanted to build websites in 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.

Services

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

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.

Example:

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 written in Swift.

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.

GUI

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.