idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
idfxx::http::ssl_server Class Reference

HTTPS server with TLS support. More...

Inheritance diagram for idfxx::http::ssl_server:
idfxx::http::server

Classes

struct  config
 HTTPS server configuration. More...
 

Public Member Functions

 ssl_server (config cfg)
 Creates and starts an HTTPS server.
 
 ~ssl_server () override=default
 
 ssl_server (const ssl_server &)=delete
 
ssl_serveroperator= (const ssl_server &)=delete
 
 ssl_server (ssl_server &&) noexcept=default
 Move constructor.
 
ssl_serveroperator= (ssl_server &&) noexcept=default
 Move assignment.
 
- Public Member Functions inherited from idfxx::http::server
 server (config cfg)
 Creates and starts an HTTP server.
 
virtual ~server ()
 Stops the server and releases all resources.
 
 server (const server &)=delete
 
serveroperator= (const server &)=delete
 
 server (server &&) noexcept
 Move constructor.
 
serveroperator= (server &&) noexcept
 Move assignment.
 
void on (enum method m, std::string uri, handler_type handler)
 Registers a URI handler for a specific HTTP method.
 
void on_any (std::string uri, handler_type handler)
 Registers a URI handler that matches any HTTP method.
 
void on_get (std::string uri, handler_type handler)
 Registers a GET handler.
 
void on_post (std::string uri, handler_type handler)
 Registers a POST handler.
 
void on_put (std::string uri, handler_type handler)
 Registers a PUT handler.
 
void on_patch (std::string uri, handler_type handler)
 Registers a PATCH handler.
 
void on_delete (std::string uri, handler_type handler)
 Registers a DELETE handler.
 
void on_head (std::string uri, handler_type handler)
 Registers a HEAD handler.
 
result< voidtry_on (enum method m, std::string uri, handler_type handler)
 Registers a URI handler for a specific HTTP method.
 
result< voidtry_on_any (std::string uri, handler_type handler)
 Registers a URI handler that matches any HTTP method.
 
result< voidtry_on_get (std::string uri, handler_type handler)
 Registers a GET handler.
 
result< voidtry_on_post (std::string uri, handler_type handler)
 Registers a POST handler.
 
result< voidtry_on_put (std::string uri, handler_type handler)
 Registers a PUT handler.
 
result< voidtry_on_patch (std::string uri, handler_type handler)
 Registers a PATCH handler.
 
result< voidtry_on_delete (std::string uri, handler_type handler)
 Registers a DELETE handler.
 
result< voidtry_on_head (std::string uri, handler_type handler)
 Registers a HEAD handler.
 
void unregister_handler (enum method m, std::string_view uri)
 Unregisters a URI handler.
 
result< voidtry_unregister_handler (enum method m, std::string_view uri)
 Unregisters a URI handler.
 
void close_session (int sockfd)
 Closes a client session by socket file descriptor.
 
result< voidtry_close_session (int sockfd)
 Closes a client session by socket file descriptor.
 
httpd_handle_t idf_handle () const noexcept
 Returns the underlying ESP-IDF HTTP server handle.
 

Static Public Member Functions

static result< ssl_servermake (config cfg)
 Creates and starts an HTTPS server.
 
- Static Public Member Functions inherited from idfxx::http::server
static result< servermake (config cfg)
 Creates and starts an HTTP server.
 

Additional Inherited Members

- Public Types inherited from idfxx::http::server
enum class  errc : esp_err_t {
  handlers_full = 0xb001 ,
  handler_exists = 0xb002 ,
  invalid_request = 0xb003 ,
  result_truncated = 0xb004 ,
  resp_header = 0xb005 ,
  resp_send = 0xb006 ,
  alloc_mem = 0xb007 ,
  task = 0xb008
}
 Error codes for HTTP server operations. More...
 
using handler_type = std::move_only_function< result< void >(request &) const >
 Handler function type for URI handlers.
 

Detailed Description

HTTPS server with TLS support.

Extends server with TLS encryption. Inherits all handler registration, request/response, WebSocket, and session management APIs.

Functions taking server& accept both HTTP and HTTPS servers, while functions requiring ssl_server& enforce that only HTTPS servers are used.

Certificate data (PEM strings) is consumed during server creation — ESP-IDF copies all certificate buffers internally, so the strings do not need to outlive the call.

Definition at line 53 of file ssl_server.hpp.

Constructor & Destructor Documentation

◆ ssl_server() [1/3]

idfxx::http::ssl_server::ssl_server ( config  cfg)
explicit

Creates and starts an HTTPS server.

.server_port = 443,
.server_cert = server_cert_pem,
.private_key = server_key_pem,
});
req.set_content_type("application/json");
req.send(R"({"status": "ok"})");
return {};
});
Non-owning view of an HTTP request.
Definition server.hpp:58
void on_get(std::string uri, handler_type handler)
Registers a GET handler.
Definition server.hpp:641
HTTPS server with TLS support.
std::expected< T, std::error_code > result
result type wrapping a value or error code.
Definition error.hpp:120
Parameters
cfgServer configuration including TLS certificates.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure.

◆ ~ssl_server()

idfxx::http::ssl_server::~ssl_server ( )
overridedefault

◆ ssl_server() [2/3]

idfxx::http::ssl_server::ssl_server ( const ssl_server )
delete

◆ ssl_server() [3/3]

idfxx::http::ssl_server::ssl_server ( ssl_server &&  )
defaultnoexcept

Move constructor.

Transfers server ownership.

Member Function Documentation

◆ make()

static result< ssl_server > idfxx::http::ssl_server::make ( config  cfg)
static

Creates and starts an HTTPS server.

Parameters
cfgServer configuration including TLS certificates.
Returns
The new HTTPS server, or an error.

◆ operator=() [1/2]

ssl_server & idfxx::http::ssl_server::operator= ( const ssl_server )
delete

◆ operator=() [2/2]

ssl_server & idfxx::http::ssl_server::operator= ( ssl_server &&  )
defaultnoexcept

Move assignment.

Transfers server ownership.


The documentation for this class was generated from the following file: