🏎 mod_swift for M1 Homebrew
I am pleased to announce that mod_swift now runs w/ Xcode 13.3.1,
on macOS 12 M1 Macs, with the native Homebrew installed in /opt
!
A neat way to write Apache modules in Swift 5.
May 8, 2022 | Read More |
Apache modules in Swift
mod_swift allows you to write native modules for the Apache Web Server in the Swift programming language.
We recommend using it with the Homebrew Apache 2.6 on macOS:
brew install httpd
or the same on Linux (tested on various Ubuntu versions).
We provide a few examples: a ‘raw’ Apache Module, a demo for the bundled Express, as well as a TodoMVC backend. But here you go, the “standard” Node example, a HelloWorld webpage:
func expressMain() {
apache.onRequest { req, res in
res.writeHead(200, [ "Content-Type": "text/html" ])
try res.end("<h1>Hello World</h1>")
}
}
Middleware using Express features like Mustache templates or JSON support:
let app = apache.express(bodyParser.urlencoded(),
cookieParser(), session())
app.get("/express/cookies") { req, res, _ in
try res.json(req.cookies) // returns all cookies as JSON
}
app.get("/express/") { req, res, _ in
let tagline = arc4random_uniform(taglines.count)
let values : [ String : Any ] = [
"tagline" : taglines[tagline],
"viewCount" : req.session["viewCount"] ?? 0,
"cowOfTheDay" : cows.vaca()
]
try res.render("index", values)
}
Access a SQL database using Apache mod_dbd:
guard let con = req.dbdAcquire() else { return ... }
guard let res = con.select("SELECT * FROM pets") else { return ... }
while let row = res.next() {
req.puts("<li>\(row[0])</li>")
}
The documentation can be found here: docs.mod-swift.org.
I am pleased to announce that mod_swift now runs w/ Xcode 13.3.1,
on macOS 12 M1 Macs, with the native Homebrew installed in /opt
!
A neat way to write Apache modules in Swift 5.
May 8, 2022 | Read More |
I am pleased to announce that mod_swift now runs w/ Xcode 10.2 and Swift 5! A neat way to write Apache modules in Swift 3, 4 or 5.
May 12, 2019 | Read More |
Breaking news: mod_swift got turned into a small standalone project. And a much enhanced ApacheExpress is becoming its own - separate - project.
May 31, 2017 | Read More |
Running Swift server applications in a huge datacenter? That is for noobs. Running Swift server applications on a Raspberry Pi, that is 1337! And now you can …
April 21, 2017 | Read More |
As part of mod_swift we have been shipping mods_todomvc. Which is an implementation of a Todo-Backend, a simple JSON API to access and modify a list of todos. Today we take Todo-Backend one step further: Access the todos using CalDAV!
February 14, 2017 | Read More |
A feature of Apache 2 known to few is mod_dbd. Using that you can configure a SQL database connection within the Apache.conf and use that within all your Apache modules/handlers.
February 6, 2017 | Read More |
I am pleased to announce the first demo release of mod_swift! A neat way to write Apache modules in Swift.
January 25, 2017 | Read More |