Skip to content

Commit

Permalink
type alias (#499)
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos authored Jan 19, 2024
1 parent 2999e7a commit 1d3df40
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/cinatra/coro_http_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,4 +713,8 @@ class coro_http_server {
coro_http_router router_;
bool need_shrink_every_time_ = false;
};

using http_server = coro_http_server;
using request = coro_http_request;
using response = coro_http_response;
} // namespace cinatra
13 changes: 13 additions & 0 deletions tests/test_coro_http_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,19 @@ TEST_CASE("get post") {
server.stop();
}

TEST_CASE("test alias") {
http_server server(1, 9001);
server.set_http_handler<GET>("/", [](request &req, response &resp) {
resp.set_status_and_content(status_type::ok, "ok");
});
server.async_start();
std::this_thread::sleep_for(300ms);

coro_http_client client{};
auto result = client.get("http://127.0.0.1:9001/");
CHECK(result.resp_body == "ok");
}

struct log_t : public base_aspect {
bool before(coro_http_request &, coro_http_response &) {
std::cout << "before log" << std::endl;
Expand Down

0 comments on commit 1d3df40

Please sign in to comment.