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
Definition: utf-8.h:11
Definition: utf-8.h:9
An HTTP request.
Definition: http_request.h:28
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