Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[new lib]coro_http_server #475

Merged
merged 2 commits into from
Oct 17, 2023
Merged

[new lib]coro_http_server #475

merged 2 commits into from
Oct 17, 2023

Conversation

qicosmos
Copy link
Collaborator

Why

add new lib: coro_http_server

What is changing

Example

  coro_http::coro_http_server server(1, 9001);
  server.set_http_handler<coro_http::GET, coro_http::POST>(
      "/", [](coro_http_request &req, coro_http_response &resp) {
        // response in io thread.
        resp.set_status_and_content(coro_http::status_type::ok, "hello world");
      });

  server.set_http_handler<coro_http::GET, coro_http::POST>(
      "/coro",
      [](coro_http_request &req,
         coro_http_response &resp) -> async_simple::coro::Lazy<void> {
        co_await coro_io::post([&]() {
          // coroutine in other thread.
          resp.set_status_and_content(coro_http::status_type::ok,
                                      "hello world in coro");
        });
      });

  server.sync_start();

@qicosmos qicosmos merged commit a682d7e into alibaba:main Oct 17, 2023
30 checks passed
@qicosmos qicosmos deleted the coro_http_server branch October 17, 2023 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant