Http Server: Code Cleanup in routes and matchrules

A clean up patch that modify the camel case to snake case and a bit
formatting

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Http Server: Simplify the route API

When adding a rule matcher, i.e. when the url that needs matching
contain a parameter, the api can be a bit complicated.  To simplify the
routes API the semantic of the put method that adds a match was
modified.

To add a match without parameters e.g. '/ui' the api would be
route.put(handler,GET,'ui')

To add a match with a parameter name e.g. '/file/{path}'

route.put(handler,GET,'/file','path')

When the put method creates a matching rule, it returns that which
allows concatination of additional parameters, e.g.
'/file/{action}/{path}

route.put(handler,GET,'/file','action')->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: Rename parser to transformer

Transformer are used to modify content return from file, previous name
parser, could be confusing. The base class for file content
transformation is file_transformer and the method is transform

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

The file_transformer is an option to modify 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 transformer would replace the
{{Host}} with the host identifier taken from the request (ie.
192.168.122.89:8000)

To simplify using the transformer, 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

find_first return the first character from the given string and not the
location of the given string.

In practice in the code the url parameter that would be passed to its
search string will start with a slash, and becasue that so do the url,
this call will always return 0 and this part of the if, will succeed.
Consider this case: url = "/ui/os" param="/uiabc" those two are
different, and find will return npos, but find_first will return 0 and
the entire if will evaluate to true.

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 transformer

When the http server reads a file from the disk, it is sometimes
required that the file content will be transform 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 transformer will look for a variable in the file (given that it has
the right extension) and will replace it.

Currently it only support {{Host}} variable, additional variable 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 Swagger 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>