MXS-1220: Add versioned URLs

Added versioning to URLs. This should allow somewhat safe modification to
the API after it has been finished.
This commit is contained in:
Markus Mäkelä
2017-05-02 16:34:41 +03:00
parent 0ea58ea6bc
commit b2e94fc73c
5 changed files with 49 additions and 15 deletions

View File

@ -26,6 +26,9 @@
#include "http.hh"
// The API version part of the URL
#define MXS_REST_API_VERSION "v1"
static int value_iterator(void *cls,
enum MHD_ValueKind kind,
const char *key,
@ -160,6 +163,14 @@ public:
{
return m_hostname.c_str();
}
/**
* @brief Drop the API version prefix
*
* @return True if prefix is present and was successfully removed
*/
bool validate_api_version();
private:
/** Constants */
@ -173,5 +184,5 @@ private:
std::deque<std::string> m_resource_parts; /**< @c m_resource split into parts */
std::string m_verb; /**< Request method */
std::string m_hostname; /**< The value of the Host header */
struct MHD_Connection* m_connection;
struct MHD_Connection* m_connection;
};

View File

@ -30,6 +30,7 @@
#define HTTP_RESPONSE_HEADER_LAST_MODIFIED "Last-Modified"
#define HTTP_RESPONSE_HEADER_ETAG "ETag"
#define HTTP_RESPONSE_HEADER_ACCEPT "Accept"
#define HTTP_RESPONSE_HEADER_CONTENT_TYPE "Content-Type"
typedef std::map<std::string, std::string> Headers;