https://mooseframework.inl.gov
Public Member Functions | Private Attributes | List of all members
WebServerControl::Request Struct Reference

Represents a request from the client. More...

#include <WebServerControl.h>

Public Member Functions

 Request ()=default
 
bool hasJSON () const
 
const nlohmann::json & getJSON () const
 
void setJSON (const nlohmann::json &json, const Moose::PassKey< WebServerControl >)
 Set the JSON data in the request. More...
 

Private Attributes

std::optional< nlohmann::json > _json
 The underlying JSON data, if any. More...
 

Detailed Description

Represents a request from the client.

Definition at line 96 of file WebServerControl.h.

Constructor & Destructor Documentation

◆ Request()

WebServerControl::Request::Request ( )
default

Member Function Documentation

◆ getJSON()

const nlohmann::json & WebServerControl::Request::getJSON ( ) const
Returns
Get the JSON data from the request

Definition at line 820 of file WebServerControl.C.

Referenced by WebServerControl::addServerActionsInternal().

821 {
822  if (!hasJSON())
823  throw std::runtime_error("Request does not contain JSON when it should");
824  return *_json;
825 }
std::optional< nlohmann::json > _json
The underlying JSON data, if any.

◆ hasJSON()

bool WebServerControl::Request::hasJSON ( ) const
inline
Returns
Whether or not the request has JSON data

Definition at line 103 of file WebServerControl.h.

Referenced by getJSON().

103 { return _json.has_value(); }
std::optional< nlohmann::json > _json
The underlying JSON data, if any.

◆ setJSON()

void WebServerControl::Request::setJSON ( const nlohmann::json &  json,
const Moose::PassKey< WebServerControl  
)
inline

Set the JSON data in the request.

Definition at line 113 of file WebServerControl.h.

114  {
115  _json = json;
116  }
std::optional< nlohmann::json > _json
The underlying JSON data, if any.

Member Data Documentation

◆ _json

std::optional<nlohmann::json> WebServerControl::Request::_json
private

The underlying JSON data, if any.

Definition at line 120 of file WebServerControl.h.

Referenced by getJSON(), hasJSON(), and setJSON().


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