blob: a3736805e3bcdc381c46fa7c1662f386e6125735 [file] [log] [blame]
Alex Vakulenko039da312015-02-03 08:58:55 -08001// 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 Vakulenko83e66cd2015-04-24 14:51:58 -07008#include <memory>
9
Alex Vakulenko039da312015-02-03 08:58:55 -080010#include <libwebserv/request.h>
11#include <libwebserv/response.h>
12
13namespace 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.
19class RequestHandlerInterface {
20 public:
Alex Vakulenko83e66cd2015-04-24 14:51:58 -070021 using HandlerSignature =
22 void(std::unique_ptr<Request>, std::unique_ptr<Response>);
Alex Vakulenko24ca76d2015-05-22 15:47:01 -070023 virtual ~RequestHandlerInterface() = default;
Alex Vakulenko039da312015-02-03 08:58:55 -080024
Alex Vakulenko83e66cd2015-04-24 14:51:58 -070025 virtual void HandleRequest(std::unique_ptr<Request> request,
26 std::unique_ptr<Response> response) = 0;
Alex Vakulenko039da312015-02-03 08:58:55 -080027};
28
29} // namespace libwebserv
30
31#endif // WEBSERVER_LIBWEBSERV_REQUEST_HANDLER_INTERFACE_H_