Akka HTTP server with plug-and-play components.
import com.spinpi.http.directives.AccessLoggingFilter
import com.spinpi.http.routes.HttpRoute
import com.spinpi.http.HttpServer
class PingRoute extends HttpRoute {
override def route: Route = path("ping") {
complete("pong")
}
}
object ExampleServer extends HttpServer with App {
router
.addPreFilter[AccessLoggingFilter]
.add[PingRoute]
startHttpServer()
}
All components are Akka HTTP directives, organized as diagram below.
+------------------------------------------+
|PreFilters |
| +------------------------------------+ |
| | Exception & Rejection handler | |
| | +-----------------------------+ | |
| | | Filters | | |
| | | +----------------------+ | | |
| | | | Routes | | | |
| | | +----------------------+ | | |
| | +-----------------------------+ | |
| +------------------------------------+ |
+------------------------------------------+
- PreFilters can be useful for request/response logging, measurement
See com.spinpi.graphql.examples.GraphQLServer
- Middlewares
- Playground