Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/httproute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,32 @@ Input::Input(const QString& inputname, const std::set<qttp::HttpPath>& path) :
{
}

Input::Input(const QString& inputname, const QString& dataType, const std::set<qttp::HttpPath>& paths) :
name(inputname),
description(),
isRequired(false),
paramType("query"),
dataType(dataType),
values(),
visibility(Visibility::Show),
paths(paths)
{
}

Input::Input(const QString& inputname, const QString& dataType, const QString& desc, const std::set<qttp::HttpPath>& paths) :
name(inputname),
description(desc),
isRequired(false),
paramType("query"),
dataType(dataType),
values(),
visibility(Visibility::Show),
paths(paths)
{
}



Input::Input(const QString& inputname, const QString& desc, const QStringList& vals, const std::set<qttp::HttpPath>& path) :
name(inputname),
description(desc),
Expand Down
2 changes: 2 additions & 0 deletions src/httproute.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class QTTPSHARED_EXPORT Input
Input(Input&& from);
Input(const Input& from);
Input(const QString& name, const std::set<qttp::HttpPath>& paths = std::set<qttp::HttpPath>());
Input(const QString& name, const QString& dataType, const std::set<qttp::HttpPath>& paths = std::set<qttp::HttpPath>());
Input(const QString& name, const QString& dataType, const QString& desc, const std::set<qttp::HttpPath>& paths = std::set<qttp::HttpPath>());
Input(const QString& name, const QString& desc, const QStringList& values, const std::set<qttp::HttpPath>& paths = std::set<qttp::HttpPath>());

Input& operator=(const Input& from);
Expand Down
13 changes: 13 additions & 0 deletions src/httpserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,19 @@ class QTTPSHARED_EXPORT HttpServer : public QObject
return action;
}

template<class T, class P> std::shared_ptr<Action> addActionAndRegister(P& param,
Visibility visibilty = Visibility::Show)
{
std::shared_ptr<Action> action(new T(param));
HttpServer::addAction(action);
auto routes = action->getRoutes();
for(const auto & path : routes)
{
HttpServer::registerRoute(action, path, visibilty);
}
return action;
}

/**
* @brief A template method to register a processor via the Processor interface.
*/
Expand Down
6 changes: 4 additions & 2 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@

<script type="text/javascript">
$(function() {
var ip = window.location.hostname;
var url = window.location.search.match(/url=([^&]+)/);
if (url && url.length > 1) {
url = decodeURIComponent(url[1]);
} else {
url = "http://localhost:8080/swagger";
url = "http://" + ip + ":8080/swagger";
}

hljs.configure({
Expand All @@ -56,6 +57,7 @@
}
window.swaggerUi = new SwaggerUi({
url: url,
validatorUrl : null,
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
onComplete: function(swaggerApi, swaggerUi) {
Expand Down Expand Up @@ -102,7 +104,7 @@
<body class="swagger-section">
<div id='header'>
<div class="swagger-ui-wrap">
<a id="logo" href="http://swagger.io"><img class="logo__img" alt="swagger" height="30" width="30" src="images/logo_small.png" /><span class="logo__title" id="logo_title"></span></a>
<a idz="logo" href="http://swagger.io"><img class="logo__img" alt="swagger" height="30" width="30" src="images/logo_small.png" /><span class="logo__title" id="logo_title"></span></a>
<form id='api_selector'>
<div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text" /></div>
<div id='auth_container'></div>
Expand Down