Files
scylladb/api/api.cc
Amnon Heiman 72c034abe1 Http API: Add Swagger-UI support
This patch adds support to the Swagger-UI. It does so by adding
reference to the Swagger-UI target directory, after applying this patch
/ui/ will display the Swagger-UI page with the available APIs.

From the Swagger-UI page it is possible to run the different APIs.

The target directory of the ui can be override from the command line.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-06-25 16:41:38 +03:00

61 lines
2.0 KiB
C++

/*
* Copyright 2015 Cloudius Systems
*/
#include "api.hh"
#include "http/file_handler.hh"
#include "http/transformers.hh"
#include "http/api_docs.hh"
#include "storage_service.hh"
#include "commitlog.hh"
#include "gossiper.hh"
#include "failure_detector.hh"
#include "column_family.hh"
#include "messaging_service.hh"
#include "storage_proxy.hh"
#include "cache_service.hh"
namespace api {
future<> set_server(http_context& ctx) {
auto rb = std::make_shared < api_registry_builder > ("api/api-doc/");
return ctx.http_server.set_routes([rb, &ctx](routes& r) {
httpd::directory_handler* dir = new httpd::directory_handler(ctx.api_dir,
new content_replace("html"));
r.put(GET, "/ui", new httpd::file_handler(ctx.api_dir + "/index.html",
new content_replace("html")));
r.add(GET, url("/ui").remainder("path"), dir);
rb->set_api_doc(r);
rb->register_function(r, "storage_service",
"The storage service API");
set_storage_service(ctx,r);
rb->register_function(r, "commitlog",
"The commit log API");
set_commitlog(ctx,r);
rb->register_function(r, "gossiper",
"The gossiper API");
set_gossiper(ctx,r);
rb->register_function(r, "column_family",
"The column family API");
set_column_family(ctx, r);
rb->register_function(r, "failure_detector",
"The failure detector API");
set_failure_detector(ctx,r);
rb->register_function(r, "messaging_service",
"The messaging service API");
set_messaging_service(ctx, r);
rb->register_function(r, "storage_proxy",
"The storage proxy API");
rb->register_function(r, "cache_service",
"The cache service API");
set_cache_service(ctx,r);
});
}
}