Crow  1.1
A C++ microframework for the web
utf-8.h
1 #pragma once
2 #include "crow/http_request.h"
3 #include "crow/http_response.h"
4 
5 namespace crow
6 {
7 
8  struct UTF8
9  {
10  struct context
11  {};
12 
13  void before_handle(request& /*req*/, response& /*res*/, context& /*ctx*/)
14  {}
15 
16  void after_handle(request& /*req*/, response& res, context& /*ctx*/)
17  {
18  if (get_header_value(res.headers, "Content-Type").empty())
19  {
20  res.set_header("Content-Type", "text/plain; charset=utf-8");
21  }
22  }
23  };
24 
25 } // namespace crow
The main namespace of the library. In this namespace is defined the most important classes and functi...
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
Definition: utf-8.h:11
Definition: utf-8.h:9
An HTTP request.
Definition: http_request.h:36
HTTP response.
Definition: http_response.h:34
void set_header(std::string key, std::string value)
Set the value of an existing header in the response.
Definition: http_response.h:51
ci_map headers
HTTP headers.
Definition: http_response.h:42