Server Side Swift!

Swiftfire was created with the goal to be able to create websites that are (sever side) completely written in Swift.

No more PHP.

To allow this it was necessary to reinvent the server and extend it with features that allow Swift code to inject HTML, CSS and/or Javascript into an outgoing webpage.

The result of this effort is a webserver we call Swiftfire.

Swiftfire uses a building-block approach and can easily be changed into an entirely different kind of server.

Out of the box, Swiftfire is a fully functional webserver that can deliver static, Swift-enabled websites and PHP-based websites to clients. (Yes, you don’t need PHP anymore, but if you want it, it can be used)

How it works

Swiftfire uses two methods that allow the insertion of dynamic features into a website by Swift code.

First off, there are ‘Services’. Every domain is implemented as a stack of its own ‘services’. Once an HTTP request is received for a domain, the assigned services are executed one after the other. Until finally a response is created which is then send back to the client. The static server is in fact a stack of default services that is assigned to each new domain. And of course you can create your own services.

Secondly, there are ‘Functions’. The service that will return a page to the client will scan that page first for occurrences of functions. If a function is found, it will execute that function and replace the function signature with the code that the function generated. The function itself is a Swift function that must have been registered during startup.

An example: “This page has been returned .functioncall() times”. If the name ‘functioncall’ is replaced with the actual name of a function like ‘nofPageHits’ the following happens: “This page has been returned 66 times”.

Build in support for:

  • Multiple domains.
  • HTTP 1.0 requests can be mapped to a specific domain.
  • HTTPS supported (using openSSL) with certificates per domain or one certificate for all domains.
  • Supports PHP based websites like Wordpress
  • Blacklisting
  • Sessions
  • Accounts
  • Comments (for blogs or articles)
  • Server Admin site
  • Domain setup page

Open Source

All code is open source. You are encouraged to download the source code from github and customize the Swift code as necessary for your own website/project.

Readme

Before you get going please read the readme page to get familiar with some basic terminology and the general design of Swiftfire.

Subprojects

The Swiftfire project is split into smaller projects, most of which are usable on their own:

  • BRUtils: Mostly type extensions used throughout the projects.
  • Ascii: Ascii character definitions.
  • BRBON: An in-memory storage manager.
  • KeyedCache: A general purpose dictionary like cache.
  • SwifterLog: A general purpose logging utility.
  • VJson: A JSON code interpreter/generator.
  • SwifterSockets: A collection of networking utilities at the POSIX level.
  • SecureSockets: A collection of networking utilities that implement SSL.
  • Http: An API for HTTP messages.
  • Swiftfire: The webserver.

All of these are open source and can be found on github.