| Alex Vakulenko | 039da31 | 2015-02-03 08:58:55 -0800 | [diff] [blame] | 1 | // Copyright 2014 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef WEBSERVER_LIBWEBSERV_REQUEST_HANDLER_CALLBACK_H_ |
| 6 | #define WEBSERVER_LIBWEBSERV_REQUEST_HANDLER_CALLBACK_H_ |
| 7 | |
| 8 | #include <base/callback.h> |
| 9 | #include <base/macros.h> |
| 10 | #include <libwebserv/export.h> |
| 11 | #include <libwebserv/request_handler_interface.h> |
| 12 | |
| 13 | namespace libwebserv { |
| 14 | |
| 15 | // A simple request handler that wraps a callback function. |
| 16 | // Essentially, it redirects the RequestHandlerInterface::HandleRequest calls |
| 17 | // to the provided callback. |
| 18 | class LIBWEBSERV_EXPORT RequestHandlerCallback |
| 19 | : public RequestHandlerInterface { |
| 20 | public: |
| 21 | explicit RequestHandlerCallback( |
| 22 | const base::Callback<HandlerSignature>& callback); |
| 23 | |
| 24 | void HandleRequest(scoped_ptr<Request> request, |
| 25 | scoped_ptr<Response> response) override; |
| 26 | |
| 27 | private: |
| 28 | base::Callback<HandlerSignature> callback_; |
| 29 | DISALLOW_COPY_AND_ASSIGN(RequestHandlerCallback); |
| 30 | }; |
| 31 | |
| 32 | } // namespace libwebserv |
| 33 | |
| 34 | #endif // WEBSERVER_LIBWEBSERV_REQUEST_HANDLER_CALLBACK_H_ |