Mercurial > hg > orthanc
comparison OrthancServer/OrthancHttpHandler.cpp @ 3395:0ce9b4f5fdf5
new abstraction: IHttpHandler::CreateStreamHandler()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 06 Jun 2019 18:54:27 +0200 |
parents | 4e43e67f8ecf |
children | 962e5f00744b |
comparison
equal
deleted
inserted
replaced
3394:2f82ef41bf5a | 3395:0ce9b4f5fdf5 |
---|---|
37 #include "../Core/OrthancException.h" | 37 #include "../Core/OrthancException.h" |
38 | 38 |
39 | 39 |
40 namespace Orthanc | 40 namespace Orthanc |
41 { | 41 { |
42 IHttpHandler::IStream* OrthancHttpHandler::CreateStreamHandler(RequestOrigin origin, | |
43 const char* remoteIp, | |
44 const char* username, | |
45 HttpMethod method, | |
46 const UriComponents& uri, | |
47 const Arguments& headers) | |
48 { | |
49 for (Handlers::const_iterator it = handlers_.begin(); it != handlers_.end(); ++it) | |
50 { | |
51 IHttpHandler::IStream* stream = (*it)->CreateStreamHandler( | |
52 origin, remoteIp, username, method, uri, headers); | |
53 | |
54 if (stream != NULL) | |
55 { | |
56 return stream; | |
57 } | |
58 } | |
59 | |
60 return NULL; | |
61 } | |
62 | |
63 | |
42 bool OrthancHttpHandler::Handle(HttpOutput& output, | 64 bool OrthancHttpHandler::Handle(HttpOutput& output, |
43 RequestOrigin origin, | 65 RequestOrigin origin, |
44 const char* remoteIp, | 66 const char* remoteIp, |
45 const char* username, | 67 const char* username, |
46 HttpMethod method, | 68 HttpMethod method, |
48 const Arguments& headers, | 70 const Arguments& headers, |
49 const GetArguments& getArguments, | 71 const GetArguments& getArguments, |
50 const char* bodyData, | 72 const char* bodyData, |
51 size_t bodySize) | 73 size_t bodySize) |
52 { | 74 { |
53 bool found = false; | 75 for (Handlers::const_iterator it = handlers_.begin(); it != handlers_.end(); ++it) |
54 | |
55 for (Handlers::const_iterator it = handlers_.begin(); | |
56 it != handlers_.end() && !found; ++it) | |
57 { | 76 { |
58 found = (*it)->Handle(output, origin, remoteIp, username, method, uri, | 77 if ((*it)->Handle(output, origin, remoteIp, username, method, uri, |
59 headers, getArguments, bodyData, bodySize); | 78 headers, getArguments, bodyData, bodySize)) |
79 { | |
80 return true; | |
81 } | |
60 } | 82 } |
61 | 83 |
62 return found; | 84 return false; |
63 } | 85 } |
64 | 86 |
65 | 87 |
66 void OrthancHttpHandler::Register(IHttpHandler& handler, | 88 void OrthancHttpHandler::Register(IHttpHandler& handler, |
67 bool isOrthancRestApi) | 89 bool isOrthancRestApi) |