33#ifdef PICO_HTTP_ENABLE_JWT
37 std::string token = req.
getHeader(
"Authorization");
38 if (token.empty() || token.find(
"Bearer ") != 0)
40 res.setStatus(401).send(
"{\"error\":\"Unauthorized\"}");
44 token = token.substr(7);
59 std::cout <<
"Received request: " << req.
getMethod() <<
" " << req.
getPath() << std::endl;
Macro-based debug trace system with optional SD file logging.
#define TRACE_INIT(MODULE_NAME)
Declare trace usage in a source file for a given module.
HTTP HttpResponse class for managing status, headers, body, and streaming support.
Utility functions to send standard JSON responses using nlohmann::json.
Stateless singleton class for creating and validating JWTs using HMAC-SHA256.
Middleware loggingMiddleware
Middleware definitions for HTTP routing (e.g., logging, auth). Part of the PicoFramework HTTP server....
Middleware authMiddleware
std::function< bool(HttpRequest &, HttpResponse &, const RouteMatch &)> Middleware
Function signature for middleware components.
static constexpr std::uintptr_t getTypeKey()
Forward declaration for potential routing needs.
const std::string & getMethod() const
Get the HTTP method.
const std::string & getPath() const
Get the parsed request path (without query string).
std::string getHeader(const std::string &field) const
Get a specific header field (case-insensitive).
Represents an HTTP response object.
Delegates to user or system configuration.
void sendError(HttpResponse &res, int statusCode, const std::string &code, const std::string &message)
Represents a match of a route against an incoming HTTP request.