blob: c9ce115c6d2f32ec93a8f58d5bfbb14ea2dd61c0 [file] [log] [blame]
Daniel Erat35f65872015-08-17 20:59:29 -06001// 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 Vakulenko039da312015-02-03 08:58:55 -080014
15#ifndef WEBSERVER_LIBWEBSERV_REQUEST_HANDLER_INTERFACE_H_
16#define WEBSERVER_LIBWEBSERV_REQUEST_HANDLER_INTERFACE_H_
17
Alex Vakulenko83e66cd2015-04-24 14:51:58 -070018#include <memory>
19
Alex Vakulenko039da312015-02-03 08:58:55 -080020#include <libwebserv/request.h>
21#include <libwebserv/response.h>
22
23namespace 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.
29class RequestHandlerInterface {
30 public:
Alex Vakulenko83e66cd2015-04-24 14:51:58 -070031 using HandlerSignature =
32 void(std::unique_ptr<Request>, std::unique_ptr<Response>);
Alex Vakulenko24ca76d2015-05-22 15:47:01 -070033 virtual ~RequestHandlerInterface() = default;
Alex Vakulenko039da312015-02-03 08:58:55 -080034
Alex Vakulenko83e66cd2015-04-24 14:51:58 -070035 virtual void HandleRequest(std::unique_ptr<Request> request,
36 std::unique_ptr<Response> response) = 0;
Alex Vakulenko039da312015-02-03 08:58:55 -080037};
38
39} // namespace libwebserv
40
41#endif // WEBSERVER_LIBWEBSERV_REQUEST_HANDLER_INTERFACE_H_