aboutsummaryrefslogtreecommitdiff
path: root/api/umosapi.h
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2019-09-10 16:20:11 +0200
committerneodarz <neodarz@neodarz.net>2019-09-10 16:20:11 +0200
commit1ae302dae3df2cb48c99ebdf407e490dca97d5fd (patch)
tree491e1f6ee0708ea379e3ead5f48246a36b88c0e9 /api/umosapi.h
parentcc42e3be1c2cfe357efaaa49b6d3738f037a9696 (diff)
parentcc8c1ad450667c8f6f983ba4f0d640accdcb49cf (diff)
downloadumosapicpp-1ae302dae3df2cb48c99ebdf407e490dca97d5fd.tar.xz
umosapicpp-1ae302dae3df2cb48c99ebdf407e490dca97d5fd.zip
Merge branch 'restbed_rewrite'
Diffstat (limited to 'api/umosapi.h')
-rw-r--r--api/umosapi.h101
1 files changed, 82 insertions, 19 deletions
diff --git a/api/umosapi.h b/api/umosapi.h
index 20c6d7b..a066ac9 100644
--- a/api/umosapi.h
+++ b/api/umosapi.h
@@ -1,37 +1,100 @@
#ifndef UmosapiService_H_
#define UmosapiService_H_
-#include <pistache/http.h>
-#include <pistache/description.h>
-#include <pistache/endpoint.h>
+#include <restbed>
-#include <pistache/serializer/rapidjson.h>
+#include <nlohmann/json.hpp>
-using namespace Pistache;
+namespace UmosapiService {
-class UmosapiService {
+struct tag {
+ std::string name;
+ std::string description;
+};
+
+struct Propertie {
+
+ std::string name;
+ std::string format;
+ std::string type;
+ std::string required;
+};
+
+struct Definition {
+
+ std::string name;
+ std::string type;
+ std::vector<Propertie> props;
+};
+
+struct Definitions {
+ std::vector<Definition> defs;
+};
+
+struct HttpWord {
+ std::string name;
+};
+
+struct Path {
+ std::string name;
+ std::vector<HttpWord> words;
+};
+
+struct Paths {
+ std::vector<Path> paths;
+};
+
+class Api {
public:
- UmosapiService(Address addr);
- virtual ~UmosapiService() {};
+ Api();
+ virtual ~Api() {};
- void init(size_t thr);
+ void init();
- void start(std::string swaggerui);
+ void start(int, int);
+ restbed::Service _service;
+ nlohmann::json _swagger;
+ std::vector<tag> _tags;
private:
- void createDescription();
-
- void retrieveAll(const Rest::Request& request, Http::ResponseWriter response);
+ void desc(std::string route, std::string http_word, const std::function< void ( const std::shared_ptr< restbed::Session > ) >& callback, const std::function< void(int, const std::exception&, std::shared_ptr< restbed::Session >) >& error_callback, tag tags[]);
+ void createResource();
- void addUObject(const Rest::Request& request, Http::ResponseWriter response);
+ static void retrieveAll( const std::shared_ptr< restbed::Session > session );
+ static void addUObject( const std::shared_ptr< restbed::Session > session );
+ static void deleteUObject( const std::shared_ptr< restbed::Session > session );
+ static void searchUObjectByKeyValue( const std::shared_ptr< restbed::Session > session );
+ static void swaggerEndpoint( const std::shared_ptr< restbed::Session > session );
+ static void swaggerEndpointResources( const std::shared_ptr< restbed::Session > session );
+ static void swaggerEndpointApi( const std::shared_ptr< restbed::Session > session );
- void deleteUObject(const Rest::Request& request, Http::ResponseWriter response);
+ std::shared_ptr< restbed::Resource> _resource;
+ Definition _definition;
+ Definitions _definitions;
+ Path _path;
+ Paths _paths;
+ void set_path();
+ void set_path(std::string route);
+ void set_method_handler(std::string http_word, const std::function< void ( const std::shared_ptr< restbed::Session > ) >& callback);
+ void set_error_handler(const std::function< void(int, const std::exception&, std::shared_ptr<restbed::Session>) >& error_callback);
+ void produce(std::string);
+ void consume(std::string);
+ void parameter(std::string, std::string, std::string);
+ void response(std::string err_code, std::string description, std::string schema);
+ void publish();
+ void basePath(std::string basePath);
+ void description(std::string description);
+ void title(std::string title);
+ void version(std::string version);
+ void host(std::string host);
+ void atag(std::string name, std::string description);
+ void scheme(std::string scheme);
- void searchUObjectByKeyValue(const Rest::Request& request, Http::ResponseWriter response);
+ void definition(std::string name, std::string type);
+ void propertie(std::string name, std::string format, std::string type, std::string required);
+ void swagger(std::string ui_path, std::string swagger_dir, std::string api_path);
- std::shared_ptr<Http::Endpoint> httpEndpoint;
- Rest::Description desc;
- Rest::Router router;
};
+}
#endif