158 lines
4.7 KiB
C++
158 lines
4.7 KiB
C++
/*
|
|
* (c) Copyright, Real-Time Innovations, 2022.
|
|
* All rights reserved.
|
|
*
|
|
* No duplications, whole or partial, manual or electronic, may be made
|
|
* without express written permission. Any such copies, or
|
|
* revisions thereof, must display this notice unaltered.
|
|
* This code contains trade secrets of Real-Time Innovations, Inc.
|
|
*/
|
|
|
|
#ifndef HTTP_SERVER_REQUEST_HANDLER_HPP
|
|
#define HTTP_SERVER_REQUEST_HANDLER_HPP
|
|
|
|
#include <functional>
|
|
|
|
|
|
#include "rti/apputils/http/common/Method.hpp"
|
|
#include "rti/apputils/http/common/HttpUtils.hpp"
|
|
|
|
#include "Connection.hpp"
|
|
#include "ServerProperty.hpp"
|
|
|
|
namespace rti { namespace apputils { namespace http { namespace server {
|
|
|
|
// Forward declaration
|
|
class Server;
|
|
|
|
/**
|
|
* @brief This class defines a generic interface to be implemented by each
|
|
* RequestHandler. This implies implementing a set or methods to handle
|
|
* different types of requests (e.g., POST, PUT, GET, DELETE, OPTIONS, HEAD and
|
|
* PATCH).
|
|
*/
|
|
class RequestHandler {
|
|
public:
|
|
/**
|
|
* @brief Virtual destructor of the RequestHandler class.
|
|
*/
|
|
virtual ~RequestHandler()
|
|
{ }
|
|
|
|
/**
|
|
* @brief The POST request handler is an interface to implement a method
|
|
* that addresses POST requests and generates responses.
|
|
*
|
|
* @param server Reference to the wrapper of the internal server API.
|
|
* @param connection
|
|
* @param web_server_property Reference to the web server properties.
|
|
*/
|
|
virtual void handle_post(
|
|
Server&,
|
|
Connection& connection,
|
|
const ServerProperty&)
|
|
{
|
|
connection.send_not_implemented();
|
|
}
|
|
|
|
/**
|
|
* @brief The PUT request handler is an interface to implement a method that
|
|
* addresses PUT requests and generates responses.
|
|
*
|
|
* @param server Reference to the wrapper of the internal server API.
|
|
* @param connection
|
|
* @param web_server_property Reference to the service properties.
|
|
*/
|
|
virtual void handle_put(
|
|
Server&,
|
|
Connection& connection,
|
|
const ServerProperty&)
|
|
{
|
|
connection.send_not_implemented();
|
|
}
|
|
|
|
/**
|
|
* @brief The GET request handler is an interface to implement a method that
|
|
* addresses GET requests and generates responses.
|
|
*
|
|
* @param server Reference to the wrapper of the internal server API.
|
|
* @param connection
|
|
* @param web_server_property Reference to the service properties.
|
|
*/
|
|
virtual void handle_get(
|
|
Server&,
|
|
Connection& connection,
|
|
const ServerProperty&)
|
|
{
|
|
connection.send_not_implemented();
|
|
}
|
|
|
|
/**
|
|
* @brief The DELETE request handler is an interface to implement a method
|
|
* that addresses DELETE requests and generates responses.
|
|
*
|
|
* @param server Reference to the wrapper of the internal server API.
|
|
* @param connection
|
|
* @param web_server_property Reference to the web server properties.
|
|
*/
|
|
virtual void handle_delete(
|
|
Server&,
|
|
Connection& connection,
|
|
const ServerProperty&)
|
|
{
|
|
connection.send_not_implemented();
|
|
}
|
|
|
|
/**
|
|
* @brief The OPTIONS request handler is an interface to implement a method
|
|
* that addresses OPTIONS requests and generates responses.
|
|
*
|
|
* @param server Reference to the wrapper of the internal server API.
|
|
* @param connection
|
|
* @param web_server_property Reference to the web server properties.
|
|
*/
|
|
virtual void handle_options(
|
|
Server&,
|
|
Connection& connection,
|
|
const ServerProperty&)
|
|
{
|
|
connection.send_not_implemented();
|
|
}
|
|
|
|
/**
|
|
* @brief The HEAD request handler is an interface to implement a method
|
|
* that addresses HEAD requests and generates responses.
|
|
*
|
|
* @param server Reference to the wrapper of the internal server API.
|
|
* @param connection
|
|
* @param web_server_property Reference to the web server properties.
|
|
*/
|
|
virtual void handle_head(
|
|
Server&,
|
|
Connection& connection,
|
|
const ServerProperty&)
|
|
{
|
|
connection.send_not_implemented();
|
|
}
|
|
|
|
/**
|
|
* @brief The PATCH request handler is an interface to implement a method
|
|
* that addresses PATCH requests and generates responses.
|
|
*
|
|
* @param server Reference to the wrapper of the internal server API.
|
|
* @param connection
|
|
* @param web_server_property Reference to the web server properties.
|
|
*/
|
|
virtual void handle_patch(
|
|
Server&,
|
|
Connection& connection,
|
|
const ServerProperty&)
|
|
{
|
|
connection.send_not_implemented();
|
|
}
|
|
};
|
|
|
|
}}}} // namespace rti::apputils::http::server
|
|
|
|
#endif // HTTP_SERVER_REQUEST_HANDLER_HPP
|