AnCH Framework 0.1
Another C++ Hack Framework
Loading...
Searching...
No Matches
anch::rest::Headers Class Reference

HTTP headers. More...

#include <headers.hpp>

Inheritance diagram for anch::rest::Headers:
Collaboration diagram for anch::rest::Headers:

Public Member Functions

std::optional< std::vector< std::string > > get (const std::string &key)
const std::optional< const std::vector< std::string > > get (const std::string &key) const
bool has (const std::string &key) const
bool add (const std::string &name, const std::vector< std::string > &values)
bool add (const std::string &name, const std::string &value)
void put (const std::string &name, const std::vector< std::string > &values)
void put (const std::string &name, const std::string &value)
std::optional< std::string > format (const std::string &name) const

Detailed Description

HTTP headers.

This class add only formatting functions to map.
Conversions are done with:

  • get will call find after formatting
  • has will call contains after formatting
  • put and add will call insert after formatting

Map methods will be masked to ensure headers formatting.

Author
Vincent Lachenal
Since
0.1

Member Function Documentation

◆ add() [1/2]

bool anch::rest::Headers::add ( const std::string & name,
const std::string & value )

Insert header if not exists

Parameters
namethe header name
valuethe header value
Returns
true when added, false otherwise (when header already exists)

◆ add() [2/2]

bool anch::rest::Headers::add ( const std::string & name,
const std::vector< std::string > & values )

Insert header if not exists

Parameters
namethe header name
valuesthe header values
Returns
true when added, false otherwise (when header already exists)

◆ format()

std::optional< std::string > anch::rest::Headers::format ( const std::string & name) const

Format header

Parameters
namethe header name
Returns
the formatted value if header exists

◆ get() [1/2]

std::optional< std::vector< std::string > > anch::rest::Headers::get ( const std::string & key)

Get header

Parameters
keythe header name to find
Returns
the value(s) when found, empty if not found

◆ get() [2/2]

const std::optional< const std::vector< std::string > > anch::rest::Headers::get ( const std::string & key) const

Get header

Parameters
keythe header name to find
Returns
the value(s) when found, empty if not found

◆ has()

bool anch::rest::Headers::has ( const std::string & key) const

Check if header has been defined

Parameters
keythe header name to find
Returns
true when header has been found, false otherwise

◆ put() [1/2]

void anch::rest::Headers::put ( const std::string & name,
const std::string & value )

Insert or replace header

Parameters
namethe header name
valuethe header value

◆ put() [2/2]

void anch::rest::Headers::put ( const std::string & name,
const std::vector< std::string > & values )

Insert or replace header

Parameters
namethe header name
valuesthe header values

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