4. Server API
Apache Pekko HTTP also provides an embedded, Reactive-Streams-based, fully asynchronous HTTP/1.1 server implemented on top of Streams.
It supports the following features:
- Full support for HTTP persistent connections
- Full support for asynchronous HTTP streaming including “chunked” transfer encoding accessible through an idiomatic API
- WebSocket support
- Optional SSL/TLS encryption
- Optional support for HTTP pipelining
The server-side components of Apache Pekko HTTP are split into two layers:
- High-level Server-Side API
- Higher-level functionality in the
pekko-http
module which offers a very flexible “Routing DSL” for elegantly defining RESTful web services as well as functionality of typical web servers or frameworks, like deconstruction of URIs, content negotiation or static content serving. - Core Server API
- The basic low-level server implementation in the
pekko-http-core
module.
Depending on your needs you can either use the low-level API directly or rely on the high-level Routing DSL which can make the definition of more complex service logic much easier. You can also interact with different API levels at the same time and, independently of which API level you choose Apache Pekko HTTP will happily serve many thousand concurrent connections to a single or many clients.
It is recommended to read the Implications of the streaming nature of Request/Response Entities section, as it explains the underlying full-stack streaming concepts, which may be unexpected when coming from a background with non-“streaming first” HTTP Servers.
- Routing DSL
- Minimal Example
- Longer Example
- Getting started
- Compared with Play framework routes
- Interaction with Actors
- Dynamic Routing Example
- Handling HTTP Server failures in the High-Level API
- File uploads
- Configuring Server-side HTTPS
- Routing DSL Overview
- Compared with Play routes
- Routes
- Directives
- Rejections
- Exception Handling
- Case Class Extraction
- Source Streaming
- Routing DSL style guide
- Route TestKit
- Core Server API
- Server WebSocket Support
- Server HTTPS Support
- Graceful termination
- Server-Side HTTP/2 (Preview)