-
-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #202 from CrowCpp/utf-8_middleware
automatic UTF-8 support
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#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"); | ||
} | ||
} | ||
}; | ||
|
||
} |