# Crow: include/crow/middlewares/utf-8.h Source File

Loading...
Searching...
No Matches
utf-8.h
#pragma once
#include "crow/http_request.h"
#include "crow/http_response.h"
namespace crow
{
struct UTF8
{
struct context
{};
void before_handle(request& /*req*/, response& /*res*/, context& /*ctx*/)
{}
void after_handle(request& /*req*/, response& res, context& /*ctx*/)
{
if (get_header_value(res.headers, "Content-Type").empty())
{
res.set_header("Content-Type", "text/plain; charset=utf-8");
}
}
};
} // namespace crow
crow
The main namespace of the library. In this namespace is defined the most important classes and functi...
crow::get_header_value
const std::string & get_header_value(const T &headers, const std::string &key)
Find and return the value associated with the key. (returns an empty string if nothing is found)
Definition http_request.h:24
crow::UTF8::context
Definition utf-8.h:11
crow::UTF8
Definition utf-8.h:9
crow::request
An HTTP request.
Definition http_request.h:36
crow::response
HTTP response.
Definition http_response.h:34
crow::response::set_header
void set_header(std::string key, std::string value)
Set the value of an existing header in the response.
Definition http_response.h:51
crow::response::headers
ci_map headers
HTTP headers.
Definition http_response.h:42