| Daniel Erat | 35f6587 | 2015-08-17 20:59:29 -0600 | [diff] [blame] | 1 | // Copyright 2015 The Android Open Source Project |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| Alex Vakulenko | 039da31 | 2015-02-03 08:58:55 -0800 | [diff] [blame] | 14 | |
| 15 | #ifndef WEBSERVER_LIBWEBSERV_REQUEST_HANDLER_INTERFACE_H_ |
| 16 | #define WEBSERVER_LIBWEBSERV_REQUEST_HANDLER_INTERFACE_H_ |
| 17 | |
| Alex Vakulenko | 83e66cd | 2015-04-24 14:51:58 -0700 | [diff] [blame] | 18 | #include <memory> |
| 19 | |
| Alex Vakulenko | 039da31 | 2015-02-03 08:58:55 -0800 | [diff] [blame] | 20 | #include <libwebserv/request.h> |
| 21 | #include <libwebserv/response.h> |
| 22 | |
| 23 | namespace libwebserv { |
| 24 | |
| 25 | // The base interface for HTTP request handlers. When registering a handler, |
| 26 | // the RequestHandlerInterface is provided, and when a request comes in, |
| 27 | // RequestHandlerInterface::HandleRequest() is called to process the data and |
| 28 | // send response. |
| 29 | class RequestHandlerInterface { |
| 30 | public: |
| Alex Vakulenko | 83e66cd | 2015-04-24 14:51:58 -0700 | [diff] [blame] | 31 | using HandlerSignature = |
| 32 | void(std::unique_ptr<Request>, std::unique_ptr<Response>); |
| Alex Vakulenko | 24ca76d | 2015-05-22 15:47:01 -0700 | [diff] [blame] | 33 | virtual ~RequestHandlerInterface() = default; |
| Alex Vakulenko | 039da31 | 2015-02-03 08:58:55 -0800 | [diff] [blame] | 34 | |
| Alex Vakulenko | 83e66cd | 2015-04-24 14:51:58 -0700 | [diff] [blame] | 35 | virtual void HandleRequest(std::unique_ptr<Request> request, |
| 36 | std::unique_ptr<Response> response) = 0; |
| Alex Vakulenko | 039da31 | 2015-02-03 08:58:55 -0800 | [diff] [blame] | 37 | }; |
| 38 | |
| 39 | } // namespace libwebserv |
| 40 | |
| 41 | #endif // WEBSERVER_LIBWEBSERV_REQUEST_HANDLER_INTERFACE_H_ |