10 Commits

Author SHA1 Message Date
Markus Mäkelä
7e18e49eec MXS-1220: Move request body checks to a higher level
The checks whether a request body is present are now done at a higher
level. This removes the need to do the checks at the resource handler
callback, removing duplicated code.

The checks are done by adding constraints to resources that must be
fulfilled by each request.

Added debug assertions to make sure that the core logic of the REST API
resource system works.
2017-08-09 11:39:24 +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ä
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ä
3deb497394 MXS-1220: Add Last-Modified and ETag headers
The resource system now tracks both the time when a resource was last
modified and the revision number of the resource. This allows working
Last-Modified and ETag headers to be generated by the REST API.

The If-Modified-Since and If-None-Match request headers are not yet
processed and using them will always return the resource instead of a 304
Not Modified response.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
47d819b008 MXS-1220: Make HTTP request handler parameters const
The HttpRequest can be const as the request itself will not be modified.
2017-05-04 09:14:04 +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ä
978af12a91 MXS-1220: Simplify resource path handling
The resources are now declared by simply typing the path that they match
and providing a callback for that path. This makes it easier to add new
resources without having to create a new class for each added resource
endpoint. It also removes some of the pathname processing that was done
inside the child class handler functions.
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ä
8b1c0cd1a1 MXS-1220: Add REST resource handler class
The Resource class is intended to be an abstraction of a resource
tree. Each node in the tree can perform actions. The tree is traversed
depth first so that deeper command paths resolve to the correct nodes.

Currently all the base resources defined in the REST API documents are
implemented in a way that they return a 200 OK response to all
requests. When the internal data can be represented as JSON, the resources
can be hooked up to functions that generate JSON.
2017-05-04 09:10:33 +03:00