Http Server: Simplify the route API

When adding a rule matcher, the api can be a bit complicated.  To
simplify the route API a rule method was added, it generate and return a
rule.

Considering that the rule /file/{path} and the handler handler. To add a
rule to the routes object that would match those url, it is possible to
call:

route.rule('/file',handler).add_param('path')

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Http Server: Code clean up and astyle handlers

This patch is a result of running astyle on the file and remove some
redundant code.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Http server: file interaction handlers complete support for file_parser

The file_praser is an option to parse a file while reading it and modify
part of its content.

For example, the Swagger json api, needs to contain an abosolute valid
url path. To do that a variable is placed inside the json file
'{{Host}}' and when a file is read, a parser would replace the {{Host}}
with the host identifier taken from the request (ie.
192.168.122.89:8000)

To simplify using the parser, it was added as an optional parameter to
the file_interaction_handler constructor and a destructor was added to
remove it.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Http Server: fix a bug in the matcher

While testing the code a bug was found in the matcher. The matcher
should use find and not find_first

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Http Server: Search a header in the request by its name

The request object holds the headers in a vector. This is because a
header can apear more than once. Sometimes it is nessary to find a
header, where only one header will be found.

The get_header method searches for the first header by its name

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Http Server: Add a file parser

When the http server reads a file from the disk, it is sometimes
required that the files will be parse and string substitution will be
perform.

For example, when reading the json files, it is required to place the
real host name/ip so the Swagger-UI will be able to use those files. The
file parser will look for a parameter in the file (given that it has the
right extension) and will replace it.

Currently it only support {{Host}} parameter, additional parameters can
be added when needed

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Http Server: Add file mapping

There are few scenarios where the httpserver should return files from
the disk in reply to a request.

The json api that are located under /usg/mgmt/api are mapped to
/api/{path}

so a call to
http://192.168.122.89:8000/api/api-docs.json
should return the api doc

The Swagge libray, that is located under /usr/mgmt/swagger-ui is mapped
to /ui so a call to
http://192.168.122.89:8000/ui/index.html
should open the Swagger GUI

The swagger index.html is mapped to /ui so a call to
http://192.168.122.89:8000/ui would also open the Swagger gui

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Http Server: Add file mapping to main

main should call the init method to initilize file mapping

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Json Swagger API: use variable for host name

The Swagger definition file holds the url of the serving host. This
cannot be hard coded, as it will vary depends on the installation.
Instead of a full host name a variable is used in the server will
replace it according to the incoming request.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
API: Adding Swagger-UI submodule

Swagger-UI is a frontend GUI for the rest API. Swagger-UI was branched
under the OSV repository and Swagger-UI is now a submodule of the mgmt
submodule

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