Skip to content

Commit 1dffa1c

Browse files
authored
Merge pull request #202 from CrowCpp/utf-8_middleware
automatic UTF-8 support
2 parents 719ecfa + 17819e6 commit 1dffa1c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

include/crow/middlewares/utf-8.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
14+
void before_handle(request& /*req*/, response& /*res*/, context& /*ctx*/)
15+
{
16+
}
17+
18+
void after_handle(request& /*req*/, response& res, context& ctx)
19+
{
20+
if (get_header_value(res.headers, "Content-Type").empty())
21+
{
22+
res.set_header("Content-Type", "text/plain; charset=utf-8");
23+
}
24+
}
25+
};
26+
27+
}

0 commit comments

Comments
 (0)