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. 14 15 #ifndef WEBSERVER_LIBWEBSERV_REQUEST_HANDLER_INTERFACE_H_ 16 #define WEBSERVER_LIBWEBSERV_REQUEST_HANDLER_INTERFACE_H_ 17 18 #include <memory> 19 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: 31 using HandlerSignature = 32 void(std::unique_ptr<Request>, std::unique_ptr<Response>); 33 virtual ~RequestHandlerInterface() = default; 34 35 virtual void HandleRequest(std::unique_ptr<Request> request, 36 std::unique_ptr<Response> response) = 0; 37 }; 38 39 } // namespace libwebserv 40 41 #endif // WEBSERVER_LIBWEBSERV_REQUEST_HANDLER_INTERFACE_H_ 42