diff options
author | attilamolnar <attilamolnar@hush.com> | 2013-05-24 19:34:25 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2013-06-07 01:00:10 +0200 |
commit | 183d7a8dc01924ac69a5d160bf1b56ccccd06a4e (patch) | |
tree | a708b167c70f4ca53d3cef2475d83a36761774de /src/modules/m_httpd.cpp | |
parent | ad523652ae0ab92df728796a1f082f339f6ddbb6 (diff) |
Change the API of m_httpd to be dynamic_reference-based
Diffstat (limited to 'src/modules/m_httpd.cpp')
-rw-r--r-- | src/modules/m_httpd.cpp | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp index 9d437bd1c..7cbef13e2 100644 --- a/src/modules/m_httpd.cpp +++ b/src/modules/m_httpd.cpp @@ -331,24 +331,37 @@ class HttpServerSocket : public BufferedSocket } }; +class HTTPdAPIImpl : public HTTPdAPIBase +{ + public: + HTTPdAPIImpl(Module* parent) + : HTTPdAPIBase(parent) + { + } + + void SendResponse(HTTPDocumentResponse& resp) CXX11_OVERRIDE + { + claimed = true; + resp.src.sock->Page(resp.document, resp.responsecode, &resp.headers); + } +}; + class ModuleHttpServer : public Module { std::vector<HttpServerSocket *> httpsocks; + HTTPdAPIImpl APIImpl; public: - void init() CXX11_OVERRIDE + ModuleHttpServer() + : APIImpl(this) { - HttpModule = this; - ServerInstance->Modules->Attach(I_OnAcceptConnection, this); } - void OnRequest(Request& request) CXX11_OVERRIDE + void init() CXX11_OVERRIDE { - if (strcmp(request.id, "HTTP-DOC") != 0) - return; - HTTPDocumentResponse& resp = static_cast<HTTPDocumentResponse&>(request); - claimed = true; - resp.src.sock->Page(resp.document, resp.responsecode, &resp.headers); + HttpModule = this; + ServerInstance->Modules->AddService(APIImpl); + ServerInstance->Modules->Attach(I_OnAcceptConnection, this); } ModResult OnAcceptConnection(int nfd, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) CXX11_OVERRIDE |