Orbit Framework
An ultra-modern, asynchronous, cross-platform C++ Web Framework.
Loading...
Searching...
No Matches
http::HttpRequest Struct Reference

Represents an incoming HTTP request. More...

#include <HttpRequest.hpp>

Public Member Functions

nlohmann::json json () const
 Parses and returns the request body as a JSON object.
 
MultipartForm form () const
 Parses the request body as multipart/form-data.
 

Public Attributes

HttpMethod method {HttpMethod::UNKNOWN}
 
std::string uri
 
std::unordered_map< std::string, std::string > query
 
std::string http_version
 
std::unordered_map< std::string_view, std::string_view, utils::CaseInsensitiveHash, utils::CaseInsensitiveEqualheaders
 
std::string_view body
 
std::unordered_map< std::string, std::string > params
 
std::unordered_map< std::string, std::string > cookies
 
std::string client_ip
 
std::string session_id
 
nlohmann::json user
 
nlohmann::json json_body
 

Detailed Description

Represents an incoming HTTP request.

Member Function Documentation

◆ form()

MultipartForm http::HttpRequest::form ( ) const
inline

Parses the request body as multipart/form-data.

Returns
MultipartForm object containing the parsed fields and files. Returns an empty form if the content type is not multipart/form-data.

◆ json()

nlohmann::json http::HttpRequest::json ( ) const
inline

Parses and returns the request body as a JSON object.

Caches the parsed JSON object for subsequent calls.

Returns
nlohmann::json object containing the parsed body, or an empty object if the body is empty or invalid.

Member Data Documentation

◆ body

std::string_view http::HttpRequest::body

◆ client_ip

std::string http::HttpRequest::client_ip

◆ cookies

std::unordered_map<std::string, std::string> http::HttpRequest::cookies

◆ headers

std::unordered_map<std::string_view, std::string_view, utils::CaseInsensitiveHash, utils::CaseInsensitiveEqual> http::HttpRequest::headers

◆ http_version

std::string http::HttpRequest::http_version

◆ json_body

nlohmann::json http::HttpRequest::json_body
mutable

◆ method

HttpMethod http::HttpRequest::method {HttpMethod::UNKNOWN}

◆ params

std::unordered_map<std::string, std::string> http::HttpRequest::params

◆ query

std::unordered_map<std::string, std::string> http::HttpRequest::query

◆ session_id

std::string http::HttpRequest::session_id

◆ uri

std::string http::HttpRequest::uri

◆ user

nlohmann::json http::HttpRequest::user

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