Skip to content
Switch branches/tags
Go to file
This branch is 79 commits ahead, 3 commits behind AlwaysRightInstitute:master.

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Swift 4 Swift 5 macOS tuxOS Travis

A micro server framework on top of SwiftNIO.

It adds an Express like API on top of the low level SwiftNIO API.

import MicroExpress

let app = Express()

app.get("/moo") { req, res, next in
app.get("/json") { _, res, _ in
  res.json([ "a": 42, "b": 1337 ])
app.get("/") { _, res, _ in


This package is part of the Always Right Institute's blog series about the Swift Server Workgroup's offical Swift HTTP API.

Please checkout Part 3 of our blog series to learn what this is about. This is a tiny framework, for a more full featured, synchronous Express-like API in Swift, have a look at ExExpress (as used in ApacheExpress). comes w/ an asynchronous variant (but is using Dispatch, not SwiftNIO - stay tuned).

Using the Package

Micro Hello World in 5 minutes (or in 30s using the swift-xcode image below):

$ mkdir MicroHelloWorld && cd MicroHelloWorld
$ swift package init --type executable

Update Package.swift to include the dependency:

// swift-tools-version:5.0
import PackageDescription

let package = Package(
  name: "MicroHelloWorld",
  dependencies: [
    .package(url: "", 
             from: "0.5.3")
  targets: [
    .target(name: "MicroHelloWorld",
            dependencies: [ "MicroExpress" ])

Change the main.swift from print("Hello World") into:

import MicroExpress

let app = Express()

app.get("/") { req, res, next in
  res.send("Hello World")

$ swift build
$ swift run

Done. Access via: http://localhost:1337/

Building the Package

Xcode 11

Using Xcode 11 one can just open the Package.swift file.

macOS / Linux Command Line

$ swift build
Completed resolution in 5.97s
Resolving at 0.5.9
Resolving at 2.12.0
[100/100] Merging module MicroExpress

Linux via macOS Docker

$ docker run --rm \
  -v "${PWD}:/src" \
  -v "${PWD}/" \
  swift:5.1.3 \
  bash -c 'cd /src && swift build'
Unable to find image 'swift:5.1.3' locally
5.1.3: Pulling from library/swift
2746a4a261c9: Pull complete 
b5d1069a5aa4: Pull complete 
Digest: sha256:72d7e583452031ae88251263649fc56ea79f98f4147474080426fb5c1ff904aa
Status: Downloaded newer image for swift:5.1.3
[99/99] Compiling MicroExpress Express.swift
[100/100] Merging module MicroExpress



MicroExpress is brought to you by the Always Right Institute and ZeeZide. We like feedback, GitHub stars, cool contract work, presumably any form of praise you can think of.

There is a #microexpress channel on the Slack. Feel free to join!

Want a Video Tutorial?

(this one is still using SwiftXcode instead of the Xcode 11 SPM support)