Usher is a simple routing library for Scala, and is built on Circlet. Routes are just Handler functions, and are easily composed. Usher is heavily inspired by Compojure.
val app: Handler = routes(
GET("/") { _ => Response(body = "Usher demo\n") },
POST("/widget") { req => ... }, // C
GET("/widget/:id{\\d+}") { req => ... }, // R
PUT("/widget/:id{\\d+}") { req => ... }, // U
DELETE("/widget/:id{\\d+}") { req => ... }, // D
notFound("Computer said no.\n")
)
JettyAdapter.run(app)
See the full example app.
Latest release:
libraryDependencies ++= Seq(
"com.markfeeney" % "usher_2.11" % "0.2.1"
)
In priority order:
- Composable routes
- Maintainable code
- Type safe
- Fast enough
- fancy type safe routes idea
context
for nesting routes a la Compojure - https://github.com/weavejester/compojure/wiki/Nesting-routes- option to index routes (trie?) for faster matching
- middleware to automatically generate Allow header (?)
Copyright © 2016 Mark Feeney
Released under the MIT license.