Http2Impl class final
#include <src/microserve/http2.cppm>
TLS HTTP/2 backend with HTTP/1.1 ALPN fallback.
Binds a TCP acceptor, loads a PEM certificate and key, and starts an HTTP/2 or HTTP/1.1 session according to the negotiated ALPN protocol.
Base classes
- struct ServerImpl
- Abstract server backend.
Constructors, destructors, conversion operators
- Http2Impl(net::io_context& ioc, const std::string& address, const unsigned short port, const std::string& cert, const std::string& key, const int verbosity = 0)
- Construct an HTTPS listener on
addressandport.
Public functions
- void set_handler(Handler h) override
- Install the request handler used by all accepted sessions.
- void start_server() override
- Start accepting TLS connections on the configured endpoint.
- void stop_server() override
- Stop accepting connections and shut down active sessions.
Function documentation
microserve:: Http2Impl:: Http2Impl(net::io_context& ioc,
const std::string& address,
const unsigned short port,
const std::string& cert,
const std::string& key,
const int verbosity = 0)
Construct an HTTPS listener on address and port.
| Parameters | |
|---|---|
| ioc | Asio I/O context that drives the acceptor and sessions. |
| address | Bind address (for example "0.0.0.0" or "::"). |
| port | TCP port to listen on. |
| cert | Path to the PEM server certificate. |
| key | Path to the PEM private key. |
| verbosity | Log verbosity (0 is quiet). |
void microserve:: Http2Impl:: set_handler(Handler h) override
Install the request handler used by all accepted sessions.
| Parameters | |
|---|---|
| h | Callback invoked for each incoming request. |
Must be called before start_