Files
MaxScale/server/core/maxscale/admin.hh
Markus Mäkelä 9d0d394361 MXS-1220: Expand HttpResponse class
The class now generates default headers. The ETag and Last-Modified tags
do not represent any actual modification time or resource hash.

The basic functionality of the HTTP responses is tested by the core test
suite. More advanced testing of the whole REST API is still required.

Removed the static `create` functions as only the JSON parsing version
could generated errors and even then the errors were unlikely. By
replacing the static creator function with a normal constructor, the
HttpResponse class can now also be created on the stack making its use
easier.
2017-05-04 09:10:33 +03:00

93 lines
1.9 KiB
C++

#pragma once
/*
* Copyright (c) 2016 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
*
* Change Date: 2019-07-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
#include <maxscale/cppdefs.hh>
#include <string>
#include <deque>
#include <maxscale/thread.h>
#include "http.hh"
#include "adminclient.hh"
using std::deque;
using std::string;
typedef deque<SAdminClient> ClientList;
/** The admin interface configuration */
struct AdminConfig
{
string host;
uint16_t port;
enum http_auth auth;
};
class AdminListener
{
public:
/**
* @brief Create a new admin interface instance
*
* @param sock Listener socket for the interface
*/
AdminListener(int sock);
~AdminListener();
/**
* Start the admin interface
*/
void start();
/**
* Stop the admin listener
*/
void stop();
/**
* Close timed out connections
*/
void check_timeouts();
private:
void handle_clients();
void handle_timeouts();
AdminClient* accept_client();
int m_socket; /**< The network socket we listen on */
int m_active; /**< Positive value if the admin is active */
int m_timeout; /**< Network timeout in seconds */
ClientList m_clients;
};
/**
* @brief Start the administrative interface
*
* @return True if the interface was successfully started
*/
bool mxs_admin_init();
/**
* @brief Shutdown the administrative interface
*/
void mxs_admin_shutdown();
/**
* @brief Get the administative interface configuration
*
* @return A reference to the administrative interface configuration
*/
AdminConfig& mxs_admin_get_config();