C++ edjLibrary SDK
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
edjx::request::HttpRequest Struct Reference

Request, which may include version, body, headers, method, and URL. More...

#include <request.hpp>

Public Member Functions

 HttpRequest ()
 Creates an empty request object with HTTP version set to HTTP/1.1, HTTP method of NONE, and no body. More...
 
http::HttpMethod get_method () const
 Returns the HTTP method of the request. More...
 
http::Uri get_uri () const
 Returns the URL from the request. More...
 
const edjx::http::HttpHeadersget_headers () const
 Returns HTTP headers of the request. More...
 
edjx::error::HttpError fetch_body ()
 Fetches the request body. More...
 
bool is_body_present () const
 Checks whether the request body has been fetched. More...
 
const std::vector< uint8_t > & get_body () const
 Returns the body associated with the request as bytes. More...
 

Static Public Member Functions

static edjx::error::HttpError from_client (HttpRequest &result, bool prefetch_body)
 Returns the client request being handled by the serverless function. More...
 

Public Attributes

http::HttpVersion version
 HTTP version of the request. More...
 
http::HttpMethod method
 HTTP method of the request. More...
 
http::Uri uri
 URL of the request. More...
 
edjx::http::HttpHeaders headers
 HTTP headers of the request. More...
 
bool body_present
 True if the request body was fetched. More...
 
std::vector< uint8_t > body
 Request body. More...
 

Detailed Description

Request, which may include version, body, headers, method, and URL.

Constructor & Destructor Documentation

◆ HttpRequest()

edjx::request::HttpRequest::HttpRequest ( )
inline

Creates an empty request object with HTTP version set to HTTP/1.1, HTTP method of NONE, and no body.

Member Function Documentation

◆ fetch_body()

edjx::error::HttpError edjx::request::HttpRequest::fetch_body ( )

Fetches the request body.

If the HTTP request body was not prefetched in the from_client function, it can be fetched by invoking this method.

Returns
Returns edjx::error::HttpError::Success on success, some other value on failure.

◆ from_client()

static edjx::error::HttpError edjx::request::HttpRequest::from_client ( HttpRequest result,
bool  prefetch_body 
)
static

Returns the client request being handled by the serverless function.

Normally, this method does not need to be used explicitly. EDJX sample C++ Serverless Application code file (main.cpp) uses this method to fetch HTTP Request.

Parameters
resultHttpRequest in which the request will be stored
prefetch_bodyBy passing the prefetch_body flag as true, the whole request body will be read from request at this function call time and then reside in the function memory.
Returns
Returns edjx::error::HttpError::Success on success, some other value if execution failed.

◆ get_body()

const std::vector< uint8_t > & edjx::request::HttpRequest::get_body ( ) const

Returns the body associated with the request as bytes.

If the HTTP request body was not prefetched, fetch_body must be called first.

Returns
Request body

◆ get_headers()

const edjx::http::HttpHeaders & edjx::request::HttpRequest::get_headers ( ) const

Returns HTTP headers of the request.

Returns the map of headers in the request as a map of header names to a vector of header values.

Returns
Request headers

◆ get_method()

http::HttpMethod edjx::request::HttpRequest::get_method ( ) const

Returns the HTTP method of the request.

Returns
HTTP method of the request

◆ get_uri()

http::Uri edjx::request::HttpRequest::get_uri ( ) const

Returns the URL from the request.

Returns the request URL value as [edjx::http::Uri] object.

Returns
URL of the request

◆ is_body_present()

bool edjx::request::HttpRequest::is_body_present ( ) const

Checks whether the request body has been fetched.

Returns
true Request body was fetched.
false Request body has not been fetched.

Member Data Documentation

◆ body

std::vector<uint8_t> edjx::request::HttpRequest::body

Request body.

◆ body_present

bool edjx::request::HttpRequest::body_present

True if the request body was fetched.

◆ headers

edjx::http::HttpHeaders edjx::request::HttpRequest::headers

HTTP headers of the request.

◆ method

http::HttpMethod edjx::request::HttpRequest::method

HTTP method of the request.

◆ uri

http::Uri edjx::request::HttpRequest::uri

URL of the request.

◆ version

http::HttpVersion edjx::request::HttpRequest::version

HTTP version of the request.


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