Crow  1.0
A C++ microframework for the web
crow::CORSRules Struct Reference

Used for tuning CORS policies. More...

Collaboration diagram for crow::CORSRules:

Public Member Functions

CORSRulesorigin (const std::string &origin)
 Set Access-Control-Allow-Origin. Default is "*". More...
 
CORSRulesmethods (crow::HTTPMethod method)
 Set Access-Control-Allow-Methods. Default is "*". More...
 
template<typename... Methods>
CORSRulesmethods (crow::HTTPMethod method, Methods... method_list)
 Set Access-Control-Allow-Methods. Default is "*". More...
 
CORSRulesheaders (const std::string &header)
 Set Access-Control-Allow-Headers. Default is "*". More...
 
template<typename... Headers>
CORSRulesheaders (const std::string &header, Headers... header_list)
 Set Access-Control-Allow-Headers. Default is "*". More...
 
CORSRulesmax_age (int max_age)
 Set Access-Control-Max-Age. Default is none. More...
 
CORSRulesallow_credentials ()
 Enable Access-Control-Allow-Credentials. More...
 
void ignore ()
 Ignore CORS and don't send any headers. More...
 
CORSRulesprefix (const std::string &prefix)
 Handle CORS on specific prefix path. More...
 
CORSRulesblueprint (const Blueprint &bp)
 Handle CORS for specific blueprint. More...
 
CORSRulesglobal ()
 Global CORS policy. More...
 

Private Member Functions

 CORSRules ()=delete
 
 CORSRules (CORSHandler *handler)
 
void add_list_item (std::string &list, const std::string &val)
 build comma separated list More...
 
void set_header_no_override (const std::string &key, const std::string &value, crow::response &res)
 Set header key to value if it is not set. More...
 
void apply (crow::response &res)
 Set response headers. More...
 

Private Attributes

bool ignore_ = false
 
std::string origin_ = "*"
 
std::string methods_ = "*"
 
std::string headers_ = "*"
 
std::string max_age_
 
bool allow_credentials_ = false
 
CORSHandlerhandler_
 

Friends

struct crow::CORSHandler
 

Detailed Description

Used for tuning CORS policies.

Constructor & Destructor Documentation

◆ CORSRules() [1/2]

crow::CORSRules::CORSRules ( )
privatedelete

◆ CORSRules() [2/2]

crow::CORSRules::CORSRules ( CORSHandler handler)
inlineprivate

Member Function Documentation

◆ origin()

CORSRules& crow::CORSRules::origin ( const std::string &  origin)
inline

Set Access-Control-Allow-Origin. Default is "*".

◆ methods() [1/2]

CORSRules& crow::CORSRules::methods ( crow::HTTPMethod  method)
inline

Set Access-Control-Allow-Methods. Default is "*".

Here is the call graph for this function:
Here is the caller graph for this function:

◆ methods() [2/2]

template<typename... Methods>
CORSRules& crow::CORSRules::methods ( crow::HTTPMethod  method,
Methods...  method_list 
)
inline

Set Access-Control-Allow-Methods. Default is "*".

Here is the call graph for this function:

◆ headers() [1/2]

CORSRules& crow::CORSRules::headers ( const std::string &  header)
inline

Set Access-Control-Allow-Headers. Default is "*".

Here is the call graph for this function:
Here is the caller graph for this function:

◆ headers() [2/2]

template<typename... Headers>
CORSRules& crow::CORSRules::headers ( const std::string &  header,
Headers...  header_list 
)
inline

Set Access-Control-Allow-Headers. Default is "*".

Here is the call graph for this function:

◆ max_age()

CORSRules& crow::CORSRules::max_age ( int  max_age)
inline

Set Access-Control-Max-Age. Default is none.

◆ allow_credentials()

CORSRules& crow::CORSRules::allow_credentials ( )
inline

Enable Access-Control-Allow-Credentials.

◆ ignore()

void crow::CORSRules::ignore ( )
inline

Ignore CORS and don't send any headers.

◆ prefix()

CORSRules & crow::CORSRules::prefix ( const std::string &  prefix)

Handle CORS on specific prefix path.

Here is the call graph for this function:

◆ blueprint()

CORSRules & crow::CORSRules::blueprint ( const Blueprint bp)

Handle CORS for specific blueprint.

Here is the call graph for this function:

◆ global()

CORSRules & crow::CORSRules::global ( )

Global CORS policy.

Here is the call graph for this function:

◆ add_list_item()

void crow::CORSRules::add_list_item ( std::string &  list,
const std::string &  val 
)
inlineprivate

build comma separated list

Here is the caller graph for this function:

◆ set_header_no_override()

void crow::CORSRules::set_header_no_override ( const std::string &  key,
const std::string &  value,
crow::response res 
)
inlineprivate

Set header key to value if it is not set.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply()

void crow::CORSRules::apply ( crow::response res)
inlineprivate

Set response headers.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ crow::CORSHandler

friend struct crow::CORSHandler
friend

Member Data Documentation

◆ ignore_

bool crow::CORSRules::ignore_ = false
private

◆ origin_

std::string crow::CORSRules::origin_ = "*"
private

◆ methods_

std::string crow::CORSRules::methods_ = "*"
private

◆ headers_

std::string crow::CORSRules::headers_ = "*"
private

◆ max_age_

std::string crow::CORSRules::max_age_
private

◆ allow_credentials_

bool crow::CORSRules::allow_credentials_ = false
private

◆ handler_

CORSHandler* crow::CORSRules::handler_
private

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