openthread-br  0.3.0-72c0388
Public Member Functions | List of all members
otbr::rest::Response Class Reference

#include <src/rest/response.hpp>

Public Member Functions

 Response (void)
 
void SetBody (std::string &aBody)
 
std::string GetBody (void) const
 
void SetResponsCode (std::string &aCode)
 
void SetCallback (void)
 
bool NeedCallback (void)
 
void SetComplete ()
 
bool IsComplete ()
 
void SetStartTime (steady_clock::time_point aStartTime)
 
steady_clock::time_point GetStartTime () const
 
std::string Serialize (void) const
 

Detailed Description

This class implements a response class for OTBR_REST, it could be manipulated by connection instance and resource handler.

Constructor & Destructor Documentation

◆ Response()

otbr::rest::Response::Response ( void  )

The constructor to initialize a response instance.

Member Function Documentation

◆ GetBody()

std::string otbr::rest::Response::GetBody ( void  ) const

This method return a string contains the body field of this response.

Returns
A string containing the body field.

◆ GetStartTime()

steady_clock::time_point otbr::rest::Response::GetStartTime ( ) const

This method returns a timestamp of start time.

Returns
A timepoint object indicates start time.

◆ IsComplete()

bool otbr::rest::Response::IsComplete ( )

This method checks whether this response is ready to be written to buffer.

Returns
A bool value indicates whether this response is ready to be written to buffer..

◆ NeedCallback()

bool otbr::rest::Response::NeedCallback ( void  )

This method checks whether this response need to be processed by callback handler later.

Returns
A bool value indicates whether this response need to be processed by callback handler later.

◆ Serialize()

std::string otbr::rest::Response::Serialize ( void  ) const

This method serialize a response to a string that could be sent by socket later.

Returns
A string contains status line, headers and body of a response.

◆ SetBody()

void otbr::rest::Response::SetBody ( std::string &  aBody)

This method set the response body.

Parameters
[in]aBodyA string to be set as response body.

◆ SetCallback()

void otbr::rest::Response::SetCallback ( void  )

This method labels the response as need callback.

◆ SetComplete()

void otbr::rest::Response::SetComplete ( )

This method labels the response as complete which means all fields has been successfully set.

◆ SetResponsCode()

void otbr::rest::Response::SetResponsCode ( std::string &  aCode)

This method set the response code.

Parameters
[in]aCodeA string representing response code such as "404 not found".

◆ SetStartTime()

void otbr::rest::Response::SetStartTime ( steady_clock::time_point  aStartTime)

This method is used to set a timestamp. when a callback is needed and this field tells callback handler when to collect all the data and form the response.

Parameters
[in]aStartTimeA timestamp indicates when the response start to wait for callback.

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