← 返回首页
Custom Access Log For Response · Issue #281 · etr/libhttpserver · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

Custom Access Log For Response #281

New issue
New issue

Description

Hello,

This example shows how to get a custom access log at the time of request. How can I get the information at the response (I need the return HTTP response code ie 200, 404, 418)

#include <httpserver.hpp> #include <iostream> using namespace httpserver; void custom_access_log(const std::string& url) { std::cout << "ACCESSING: " << url << std::endl; } class hello_world_resource : public http_resource { public: const std::shared_ptr<http_response> render(const http_request&) { return std::shared_ptr<http_response>(new string_response("Hello, World!")); } }; int main(int argc, char** argv) { webserver ws = create_webserver(8080) .log_access(custom_access_log); hello_world_resource hwr; ws.register_resource("/hello", &hwr); ws.start(true); return 0; }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    • Open in GitHub Copilot app

    Footer

    © 2026 GitHub, Inc.