Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos committed Feb 10, 2024
1 parent 259b9f9 commit 1470c14
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ int main() {
using namespace cinatra;

//日志切面
struct log_t : public base_aspect
struct log_t
{
bool before(coro_http_request& req, coro_http_response& res) {
std::cout << "before log" << std::endl;
Expand All @@ -231,7 +231,7 @@ int main() {
};

//校验的切面
struct check : public base_aspect {
struct check {
bool before(coro_http_request& req, coro_http_response& res) {
std::cout << "before check" << std::endl;
if (req.get_header_value("name").empty()) {
Expand All @@ -248,7 +248,7 @@ int main() {
};

//将信息从中间件传输到处理程序
struct get_data : public base_aspect {
struct get_data {
bool before(coro_http_request& req, coro_http_response& res) {
req.set_aspect_data("hello world");
return true;
Expand All @@ -259,12 +259,12 @@ int main() {
coro_http_server server(std::thread::hardware_concurrency(), 8080);
server.set_http_handler<GET, POST>("/aspect", [](coro_http_request& req, coro_http_response& res) {
res.set_status_and_content(status_type::ok, "hello world");
}, std::vector{std::make_shared<check>(), std::make_shared<log_t>()});
}, check{}, log_t{});

server.set_http_handler<GET,POST>("/aspect/data", [](coro_http_request& req, coro_http_response& res) {
auto& val = req.get_aspect_data();
res.set_status_and_content(status_type::ok, std::move(val[0]));
}, std::vector{std::make_shared<get_data>()});
}, get_data{});

server.sync_start();
return 0;
Expand Down
10 changes: 5 additions & 5 deletions lang/english/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ int main() {
using namespace cinatra;

//日志切面
struct log_t : public base_aspect
struct log_t
{
bool before(coro_http_request& req, coro_http_response& res) {
std::cout << "before log" << std::endl;
Expand All @@ -216,7 +216,7 @@ int main() {
};

//校验的切面
struct check : public base_aspect {
struct check {
bool before(coro_http_request& req, coro_http_response& res) {
std::cout << "before check" << std::endl;
if (req.get_header_value("name").empty()) {
Expand All @@ -233,7 +233,7 @@ int main() {
};

//将信息从中间件传输到处理程序
struct get_data : public base_aspect {
struct get_data {
bool before(coro_http_request& req, coro_http_response& res) {
req.set_aspect_data("hello world");
return true;
Expand All @@ -244,13 +244,13 @@ int main() {
coro_http_server server(std::thread::hardware_concurrency(), 8080);
server.set_http_handler<GET, POST>("/aspect", [](coro_http_request& req, coro_http_response& res) {
res.set_status_and_content(status_type::ok, "hello world");
}, std::vector{std::make_shared<check>(), std::make_shared<log_t>()});
}, check{}, log_t{});

server.set_http_handler<GET,POST>("/aspect/data", [](coro_http_request& req, coro_http_response& res) {
auto &val = req.get_aspect_data();
std::string& hello = val[0];
res.set_status_and_content(status_type::ok, std::move(hello));
}, std::vector{std::make_shared<get_data>()});
}, get_data{});

server.sync_start();
return 0;
Expand Down

0 comments on commit 1470c14

Please sign in to comment.