spinpi / http-server   0.3.4

GitHub

A HTTP server based on Akka HTTP with GraphQL

Scala versions: 2.13 2.12 2.11

Http server

Build Status codecov

Akka HTTP server with plug-and-play components.

Basic usage

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()
}

Components

HTTP router

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

GraphQL Server

Example

See com.spinpi.graphql.examples.GraphQLServer

Customizations

  1. Middlewares
  2. Playground

HTTP render template

See com.spinpi.http.TestServerWithTemplate