21 Commits

Author SHA1 Message Date
Markus Mäkelä
19c4016e65 MXS-1220: Add to_string to HttpRequest
Allowing requests to be converted to raw HTTP requests allows them to be
propagated to other instances of MaxScale. This should allow multiple
MaxScales to perform the same action in a coherent manner.

A simple clustering mechanism needs to be added to make MaxScale aware of
other instances.
2017-06-02 12:52:33 +03:00
Markus Mäkelä
ba546fcd21 MXS-1220: Add execution of module commands to REST API
The module command self links now point to an endpoint that executes the
module command. Depending on the type of the module command, either a GET
or a POST request must be made.
2017-06-02 12:52:33 +03:00
Johan Wikman
f546a17e77 Update change date of 2.2 2017-06-01 10:24:20 +03:00
Markus Mäkelä
b6b108c8d5 MXS-1220: Fix possible crash on NULL option value
When a request option without a value is given, microhttpd exposes this as
key with a NULL value.
2017-05-26 08:52:38 +03:00
Markus Mäkelä
551f635f50 MXS-1220: Make the http.hh header public
As it contains utility functions for formatting time_t values to HTTP-date
values, there's no real need to make it an internal header.
2017-05-17 10:14:56 +03:00
Markus Mäkelä
ac21443529 MXS-1220: Make modules proper resources
The /maxscale/modules/ endpoint is now a resource collection and the
/maxscale/modules/:module endpoint exposes the individual resources.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
624434a6d4 MXS-1220: Compare headers case-insensitively
The header names are not case sensitive.
2017-05-09 15:32:41 +03:00
Markus Mäkelä
b2e94fc73c MXS-1220: Add versioned URLs
Added versioning to URLs. This should allow somewhat safe modification to
the API after it has been finished.
2017-05-09 15:32:41 +03:00
Markus Mäkelä
50eafe19fe MXS-1220: Add self links to all resources
A self link to the resource itself provides a convenient way for the
client to request a resource, modify it and call the self link to update
it. This removes some of the burden on the client to keep track of the
resource links by placing these in the resource itself.
2017-05-04 09:14:04 +03:00
Markus Mäkelä
c17c451fb5 MXS-1220: Move header generation back to HttpResponse
The actual list of headers is not known when the request is first
generated. This prevents the headers from being generated in admin.cc
which handles things on a lower level.

The moving of the header generation is done with the OPTIONS method in
mind. This header needs to be generated inside the RootResource class
which manages the navigation of the resources.
2017-05-04 09:14:03 +03:00
Markus Mäkelä
ebc9e4bd3b MXS-1220: Clean up resource, request and response headers
Cleaned up various parts of the resource, request and response class
headers.

Moved `using` declarations into .cc files.

Made the Resource class non-copyable as it isn't really meant to be
copied.
2017-05-04 09:14:03 +03:00
Markus Mäkelä
80104d6dad MXS-1220: Add POST handling for servers
New servers can now be created by POSTing a new server definition to the
/servers/ resource.
2017-05-04 09:14:03 +03:00
Markus Mäkelä
52e075963e MXS-1220: Reorganize request and response processing
The standard response headers are now generated at a higher level. This
reduces the scope of the HttpResponse class making it a leaner wrapper
around a few simple variables, namely the JSON body of the response.

The HttpRequest now exposes the Host header that the client sent. This
allows resource relations to be real links that work without modification.
2017-05-04 09:12:16 +03:00
Markus Mäkelä
d242203279 MXS-1220: Use libmicrohttpd for the HTTP handling
The HTTP side of the REST API is better handled with an actual
library. The libmicrohttpd library provides a convenient way of handling
the HTTP traffic between the clients and MaxScale.
2017-05-04 09:12:15 +03:00
Markus Mäkelä
caf2172677 MXS-1220: Fix minor problems with admin thread
The admin thread now uses blocking IO. This is not optimal but it
simplifies the code by some amount.

Fixed option processing removing one extra character from key name.

Use correct member variable when checking for the option map end.
2017-05-04 09:11:18 +03:00
Markus Mäkelä
900bf2db5a MXS-1220: Take the resource handler into use
The resource handler system is now usable but it doesn't perform anything
useful. Although, this will allows it to be tested for correctness.

Minor fixes to HttpResponse output and renaming of functions.
2017-05-04 09:10:33 +03:00
Markus Mäkelä
e248178349 MXS-1220: Split requested resource into parts
When a client requests a resource, the HttpRequest class now splits the
requested resource into parts. This should help with the resource
validation and navigation.

Added test that checks that the resources are correctly split into the
correct number of arguments and that the argument contents are correct.
2017-05-04 09:10:33 +03:00
Markus Mäkelä
34ee4a1997 MXS-1220: Add option parsing
The options of a request are now parsed and exposed by the HttpRequest
class.

Added tests for the request options.

Also added missing error handling of invalid requests.
2017-05-04 09:10:33 +03:00
Markus Mäkelä
a73d3e9276 MXS-1220: Create HTTP response class
The HTTP response class simplifies the response creation. The next step is
to add generation of all the default headers that are needed by the REST
API.
2017-05-04 09:10:32 +03:00
Markus Mäkelä
c937457738 MXS-1220: Add request body parsing
The HTTP request body is expected to be a valid JSON object. All other
requests are considered malformed requests and result in a HTTP 400 error.

Added the Jansson license to the LICENSE-THIRDPARTY.TXT file. Imported
some of the tests from the Jansson test suite to the HttpParser test.
2017-05-04 09:10:32 +03:00
Markus Mäkelä
4eb121ce35 MXS-1220: Rename and reorganize HttpParser
The HttpParser class was renamed to HttpRequest as it parses and processes
only HTTP requests. A second class that creates a HTTP response needs to
be created to handle the response generation.

Moved some of the HTTP constants and helper functions to a separate
http.hh header.
2017-05-04 09:10:32 +03:00