httpserver: build with optimizations

I'm seeing a wierd miscompile without this, but it's a good idea anyway.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
build: clean httpserver build products

Otherwise wierd miscompilations pop up all over the place if there are
dependency issues (and there are).

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
httpserver: add build dependencies

Or chase mysterious bugs forever.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Http Server: Clean up in the lambda expression handlers

To simplify the use of lambda expression as handlers, the function type
was define, and additional function was added, a one that gets not only
the request but also the reply, this will allow using
lambda expression in more complicated scenarios then before.

The function handler was modified to use the more general function and a
temporary function is used to do the translation.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Http Server: handler to support mandatory parameters

Mandatory parameters are query parameters that the handler expect to
exists before starting the handler logic.

The handler now holds a list of mandatory parameter, that will be verify
before the handler is called.

The handler logic can safely assume all the mandatory parameters are
there and doesn't need to verify it.
If the parameters are missing a 400 will be return with the appropriate
error message.

The code generator will automatically adds any mandatory parameter from
the Swagger definition file. But it is also possible to add additional
parameters.

if h is the handler calling:
h.mandatory("op");

will add the query parameter "op" as a mandatory parameter

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Http Server: add mandatory parameters to the path

The path object that holds the information form the Swagger definition
file now holds a list of mandatory parameters.

Those parameters will be used to validate that mandatory parameters are
included before calling the handler logic.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Http server: Add a parameter not found exception

When a mandatory parameter is missing a missing mandatory exception will
be thrown.

The exception constructor gets the parameter name is a parameter.
It will return a 400 bad request.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Http Server: Add mandatory parameters support to the routes

The routes object now copy mandatory parameters from the path object to
the handler and uses the mandatory parameters in the handler to verify
that the mandatory parameters are in the request before calling the
handler logic.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Http server: Adding path holder

Path holder is an object that simplifies setting a handler to an api
define in the Swagger definition file.

The code generation will set a path holder object for each of the api
calls. For example to the api action "getFile" the following will be
define:

static const path_holder getFile("getFile");

getFile can now be used to set a handler to the operation. So if h is a
handler you can do:

getFile.set_handler(h);

It also support lamda expression, so if f is a request_function (as
define in the handlers.hh file) you can do:

getFile.set_handler(f,"json");

With the new API there is no need to access the routes object in most
cases.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Http server: code generation to support mandatory parameters

Mandatory query parameters are now set with the path description

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Http Server: Code generation declare path holder

Path holder replaces the constant name of the operation, the code
generation uses them instead of string.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Http Server: Initilialize the path_holder

The path_holder holds a pointer to the routes object. The main should
initialize it after creating the routes object.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Http Server: file.cc to use new API

The changed API, changed how a handler is set for an action, the file.cc
was modified to use the new API.

So setting a handler becomes:
getFile.set_handler(new get_file_handler());

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>