| 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_INTERFACE_H_ |
| 6 | #define WEBSERVER_LIBWEBSERV_REQUEST_HANDLER_INTERFACE_H_ |
| 7 | |
| Alex Vakulenko | 83e66cd | 2015-04-24 14:51:58 -0700 | [diff] [blame] | 8 | #include <memory> |
| 9 | |
| Alex Vakulenko | 039da31 | 2015-02-03 08:58:55 -0800 | [diff] [blame] | 10 | #include <libwebserv/request.h> |
| 11 | #include <libwebserv/response.h> |
| 12 | |
| 13 | namespace libwebserv { |
| 14 | |
| 15 | // The base interface for HTTP request handlers. When registering a handler, |
| 16 | // the RequestHandlerInterface is provided, and when a request comes in, |
| 17 | // RequestHandlerInterface::HandleRequest() is called to process the data and |
| 18 | // send response. |
| 19 | class RequestHandlerInterface { |
| 20 | public: |
| Alex Vakulenko | 83e66cd | 2015-04-24 14:51:58 -0700 | [diff] [blame] | 21 | using HandlerSignature = |
| 22 | void(std::unique_ptr<Request>, std::unique_ptr<Response>); |
| Alex Vakulenko | 24ca76d | 2015-05-22 15:47:01 -0700 | [diff] [blame] | 23 | virtual ~RequestHandlerInterface() = default; |
| Alex Vakulenko | 039da31 | 2015-02-03 08:58:55 -0800 | [diff] [blame] | 24 | |
| Alex Vakulenko | 83e66cd | 2015-04-24 14:51:58 -0700 | [diff] [blame] | 25 | virtual void HandleRequest(std::unique_ptr<Request> request, |
| 26 | std::unique_ptr<Response> response) = 0; |
| Alex Vakulenko | 039da31 | 2015-02-03 08:58:55 -0800 | [diff] [blame] | 27 | }; |
| 28 | |
| 29 | } // namespace libwebserv |
| 30 | |
| 31 | #endif // WEBSERVER_LIBWEBSERV_REQUEST_HANDLER_INTERFACE_H_ |