Mercurial > hg > orthanc
changeset 975:c550e99c452b
refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 30 Jun 2014 14:53:18 +0200 |
parents | 83622b0f544c |
children | 6968356679c0 ce3106e5843f |
files | Core/RestApi/RestApi.cpp Core/RestApi/RestApiCall.h Core/RestApi/RestApiDeleteCall.h Core/RestApi/RestApiGetCall.h Core/RestApi/RestApiHierarchy.cpp Core/RestApi/RestApiHierarchy.h Core/RestApi/RestApiPath.cpp Core/RestApi/RestApiPath.h Core/RestApi/RestApiPostCall.h Core/RestApi/RestApiPutCall.h UnitTestsSources/RestApiTests.cpp |
diffstat | 11 files changed, 40 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/RestApi/RestApi.cpp Mon Jun 30 14:44:05 2014 +0200 +++ b/Core/RestApi/RestApi.cpp Mon Jun 30 14:53:18 2014 +0200 @@ -166,7 +166,7 @@ { bool ok = false; RestApiOutput restOutput(output); - RestApiPath::Components components; + HttpHandler::Arguments components; UriComponents trailing; if (method == HttpMethod_Get)
--- a/Core/RestApi/RestApiCall.h Mon Jun 30 14:44:05 2014 +0200 +++ b/Core/RestApi/RestApiCall.h Mon Jun 30 14:53:18 2014 +0200 @@ -46,7 +46,7 @@ RestApiOutput& output_; RestApi& context_; const HttpHandler::Arguments& httpHeaders_; - const RestApiPath::Components& uriComponents_; + const HttpHandler::Arguments& uriComponents_; const UriComponents& trailing_; const UriComponents& fullUri_; @@ -58,7 +58,7 @@ RestApiCall(RestApiOutput& output, RestApi& context, const HttpHandler::Arguments& httpHeaders, - const RestApiPath::Components& uriComponents, + const HttpHandler::Arguments& uriComponents, const UriComponents& trailing, const UriComponents& fullUri) : output_(output),
--- a/Core/RestApi/RestApiDeleteCall.h Mon Jun 30 14:44:05 2014 +0200 +++ b/Core/RestApi/RestApiDeleteCall.h Mon Jun 30 14:53:18 2014 +0200 @@ -44,7 +44,7 @@ RestApiDeleteCall(RestApiOutput& output, RestApi& context, const HttpHandler::Arguments& httpHeaders, - const RestApiPath::Components& uriComponents, + const HttpHandler::Arguments& uriComponents, const UriComponents& trailing, const UriComponents& fullUri) : RestApiCall(output, context, httpHeaders, uriComponents, trailing, fullUri)
--- a/Core/RestApi/RestApiGetCall.h Mon Jun 30 14:44:05 2014 +0200 +++ b/Core/RestApi/RestApiGetCall.h Mon Jun 30 14:53:18 2014 +0200 @@ -47,7 +47,7 @@ RestApiGetCall(RestApiOutput& output, RestApi& context, const HttpHandler::Arguments& httpHeaders, - const RestApiPath::Components& uriComponents, + const HttpHandler::Arguments& uriComponents, const UriComponents& trailing, const UriComponents& fullUri, const HttpHandler::Arguments& getArguments) :
--- a/Core/RestApi/RestApiHierarchy.cpp Mon Jun 30 14:44:05 2014 +0200 +++ b/Core/RestApi/RestApiHierarchy.cpp Mon Jun 30 14:53:18 2014 +0200 @@ -32,6 +32,8 @@ #include "RestApiHierarchy.h" +#include "../OrthancException.h" + #include <cassert> namespace Orthanc @@ -163,7 +165,7 @@ } - bool RestApiHierarchy::LookupHandler(RestApiPath::Components& components, + bool RestApiHierarchy::LookupHandler(HttpHandler::Arguments& components, const UriComponents& uri, ResourceCallback callback, size_t level, @@ -198,7 +200,7 @@ for (child = wildcardChildren_.begin(); child != wildcardChildren_.end(); child++) { - RestApiPath::Components subComponents = components; + HttpHandler::Arguments subComponents = components; subComponents[child->first] = uri[level]; if (child->second->LookupHandler(components, uri, callback, level + 1, call)) @@ -280,7 +282,7 @@ bool RestApiHierarchy::GetCallback(Handlers& handlers, const UriComponents& uri, - const RestApiPath::Components& components, + const HttpHandler::Arguments& components, const UriComponents& trailing, void* call) { @@ -298,7 +300,7 @@ bool RestApiHierarchy::PostCallback(Handlers& handlers, const UriComponents& uri, - const RestApiPath::Components& components, + const HttpHandler::Arguments& components, const UriComponents& trailing, void* call) { @@ -316,7 +318,7 @@ bool RestApiHierarchy::PutCallback(Handlers& handlers, const UriComponents& uri, - const RestApiPath::Components& components, + const HttpHandler::Arguments& components, const UriComponents& trailing, void* call) { @@ -334,7 +336,7 @@ bool RestApiHierarchy::DeleteCallback(Handlers& handlers, const UriComponents& uri, - const RestApiPath::Components& components, + const HttpHandler::Arguments& components, const UriComponents& trailing, void* call) { @@ -432,28 +434,28 @@ bool RestApiHierarchy::Handle(RestApiGetCall& call, const UriComponents& uri) { - RestApiPath::Components components; + HttpHandler::Arguments components; return LookupHandler(components, uri, GetCallback, 0, &call); } bool RestApiHierarchy::Handle(RestApiPutCall& call, const UriComponents& uri) { - RestApiPath::Components components; + HttpHandler::Arguments components; return LookupHandler(components, uri, PutCallback, 0, &call); } bool RestApiHierarchy::Handle(RestApiPostCall& call, const UriComponents& uri) { - RestApiPath::Components components; + HttpHandler::Arguments components; return LookupHandler(components, uri, PostCallback, 0, &call); } bool RestApiHierarchy::Handle(RestApiDeleteCall& call, const UriComponents& uri) { - RestApiPath::Components components; + HttpHandler::Arguments components; return LookupHandler(components, uri, DeleteCallback, 0, &call); }
--- a/Core/RestApi/RestApiHierarchy.h Mon Jun 30 14:44:05 2014 +0200 +++ b/Core/RestApi/RestApiHierarchy.h Mon Jun 30 14:53:18 2014 +0200 @@ -32,12 +32,10 @@ #pragma once -#include "RestApi.h" - -#include "../OrthancException.h" - -#include <list> -#include <set> +#include "RestApiGetCall.h" +#include "RestApiPostCall.h" +#include "RestApiPutCall.h" +#include "RestApiDeleteCall.h" namespace Orthanc { @@ -47,9 +45,9 @@ class Handlers { private: - RestApiGetCall::Handler getHandler_; - RestApiPostCall::Handler postHandler_; - RestApiPutCall::Handler putHandler_; + RestApiGetCall::Handler getHandler_; + RestApiPostCall::Handler postHandler_; + RestApiPutCall::Handler putHandler_; RestApiDeleteCall::Handler deleteHandler_; public: @@ -92,7 +90,7 @@ typedef std::map<std::string, RestApiHierarchy*> Children; typedef bool (*ResourceCallback) (Handlers& handlers, const UriComponents& uri, - const RestApiPath::Components& components, + const HttpHandler::Arguments& components, const UriComponents& trailing, void* call); @@ -112,7 +110,7 @@ Handler handler, size_t level); - bool LookupHandler(RestApiPath::Components& components, + bool LookupHandler(HttpHandler::Arguments& components, const UriComponents& uri, ResourceCallback callback, size_t level, @@ -124,25 +122,25 @@ static bool GetCallback(Handlers& handlers, const UriComponents& uri, - const RestApiPath::Components& components, + const HttpHandler::Arguments& components, const UriComponents& trailing, void* call); static bool PostCallback(Handlers& handlers, const UriComponents& uri, - const RestApiPath::Components& components, + const HttpHandler::Arguments& components, const UriComponents& trailing, void* call); static bool PutCallback(Handlers& handlers, const UriComponents& uri, - const RestApiPath::Components& components, + const HttpHandler::Arguments& components, const UriComponents& trailing, void* call); static bool DeleteCallback(Handlers& handlers, const UriComponents& uri, - const RestApiPath::Components& components, + const HttpHandler::Arguments& components, const UriComponents& trailing, void* call);
--- a/Core/RestApi/RestApiPath.cpp Mon Jun 30 14:44:05 2014 +0200 +++ b/Core/RestApi/RestApiPath.cpp Mon Jun 30 14:53:18 2014 +0200 @@ -78,7 +78,7 @@ } } - bool RestApiPath::Match(Components& components, + bool RestApiPath::Match(HttpHandler::Arguments& components, UriComponents& trailing, const std::string& uriRaw) const { @@ -87,7 +87,7 @@ return Match(components, trailing, uri); } - bool RestApiPath::Match(Components& components, + bool RestApiPath::Match(HttpHandler::Arguments& components, UriComponents& trailing, const UriComponents& uri) const { @@ -135,7 +135,7 @@ bool RestApiPath::Match(const UriComponents& uri) const { - Components components; + HttpHandler::Arguments components; UriComponents trailing; return Match(components, trailing, uri); }
--- a/Core/RestApi/RestApiPath.h Mon Jun 30 14:44:05 2014 +0200 +++ b/Core/RestApi/RestApiPath.h Mon Jun 30 14:53:18 2014 +0200 @@ -33,6 +33,8 @@ #pragma once #include "../Toolbox.h" +#include "../HttpServer/HttpHandler.h" + #include <map> namespace Orthanc @@ -45,16 +47,14 @@ std::vector<std::string> components_; public: - typedef std::map<std::string, std::string> Components; - RestApiPath(const std::string& uri); // This version is slower - bool Match(Components& components, + bool Match(HttpHandler::Arguments& components, UriComponents& trailing, const std::string& uriRaw) const; - bool Match(Components& components, + bool Match(HttpHandler::Arguments& components, UriComponents& trailing, const UriComponents& uri) const;
--- a/Core/RestApi/RestApiPostCall.h Mon Jun 30 14:44:05 2014 +0200 +++ b/Core/RestApi/RestApiPostCall.h Mon Jun 30 14:53:18 2014 +0200 @@ -47,7 +47,7 @@ RestApiPostCall(RestApiOutput& output, RestApi& context, const HttpHandler::Arguments& httpHeaders, - const RestApiPath::Components& uriComponents, + const HttpHandler::Arguments& uriComponents, const UriComponents& trailing, const UriComponents& fullUri, const std::string& data) :
--- a/Core/RestApi/RestApiPutCall.h Mon Jun 30 14:44:05 2014 +0200 +++ b/Core/RestApi/RestApiPutCall.h Mon Jun 30 14:53:18 2014 +0200 @@ -47,7 +47,7 @@ RestApiPutCall(RestApiOutput& output, RestApi& context, const HttpHandler::Arguments& httpHeaders, - const RestApiPath::Components& uriComponents, + const HttpHandler::Arguments& uriComponents, const UriComponents& trailing, const UriComponents& fullUri, const std::string& data) :