Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
3d0492dc
Commit
3d0492dc
authored
Oct 31, 2016
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(UHttp): сделал поддержку передачи параметров
parent
dbc31878
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
16 deletions
+16
-16
UniSetActivator.h
include/UniSetActivator.h
+1
-1
UniSetObject.h
include/UniSetObject.h
+1
-1
UHttpRequestHandler.cc
src/Communications/Http/UHttpRequestHandler.cc
+2
-7
UniSetActivator.cc
src/ObjectRepository/UniSetActivator.cc
+3
-3
UniSetObject.cc
src/ObjectRepository/UniSetObject.cc
+1
-1
uhttp-test.cc
tests/UHttpTest/uhttp-test.cc
+8
-3
No files found.
include/UniSetActivator.h
View file @
3d0492dc
...
...
@@ -85,7 +85,7 @@ class UniSetActivator:
return
abortScript
;
}
virtual
nlohmann
::
json
getDataByName
(
const
std
::
string
&
name
)
override
;
virtual
nlohmann
::
json
getDataByName
(
const
std
::
string
&
name
,
const
Poco
::
URI
::
QueryParameters
&
p
)
override
;
protected
:
...
...
include/UniSetObject.h
View file @
3d0492dc
...
...
@@ -101,7 +101,7 @@ class UniSetObject:
//! поместить сообщение в очередь
virtual
void
push
(
const
UniSetTypes
::
TransportMessage
&
msg
)
override
;
virtual
nlohmann
::
json
getData
()
override
;
virtual
nlohmann
::
json
getData
(
const
Poco
::
URI
::
QueryParameters
&
p
)
override
;
// -------------- вспомогательные --------------
/*! получить ссылку (на себя) */
...
...
src/Communications/Http/UHttpRequestHandler.cc
View file @
3d0492dc
...
...
@@ -15,7 +15,6 @@
*/
// -------------------------------------------------------------------------
#include <ostream>
#include <Poco/URI.h>
#include "UHttpRequestHandler.h"
// -------------------------------------------------------------------------
using
namespace
std
;
...
...
@@ -62,17 +61,13 @@ void UHttpRequestHandler::handleRequest( Poco::Net::HTTPServerRequest& req, Poco
}
const
std
::
string
objectName
(
seg
[
2
]);
// auto qp = uri.getQueryParameters();
// cerr << "params: " << endl;
// for( const auto& p: qp )
// cerr << p.first << "=" << p.second << endl;
auto
qp
=
uri
.
getQueryParameters
();
resp
.
setStatus
(
HTTPResponse
::
HTTP_OK
);
resp
.
setContentType
(
"text/json"
);
std
::
ostream
&
out
=
resp
.
send
();
auto
json
=
registry
->
getDataByName
(
objectName
);
auto
json
=
registry
->
getDataByName
(
objectName
,
qp
);
out
<<
json
.
dump
();
out
.
flush
();
}
...
...
src/ObjectRepository/UniSetActivator.cc
View file @
3d0492dc
...
...
@@ -861,15 +861,15 @@ UniSetActivator::TerminateEvent_Signal UniSetActivator::signal_terminate_event()
return
s_term
;
}
// ------------------------------------------------------------------------------------------
nlohmann
::
json
UniSetActivator
::
getDataByName
(
const
string
&
name
)
nlohmann
::
json
UniSetActivator
::
getDataByName
(
const
string
&
name
,
const
Poco
::
URI
::
QueryParameters
&
p
)
{
auto
obj
=
findObject
(
name
);
if
(
obj
)
return
obj
->
getData
();
return
obj
->
getData
(
p
);
auto
man
=
findManager
(
name
);
if
(
man
)
return
man
->
getData
();
return
man
->
getData
(
p
);
//! \todo Продумать что возвращать если объект не найден
nlohmann
::
json
j
=
""
;
...
...
src/ObjectRepository/UniSetObject.cc
View file @
3d0492dc
...
...
@@ -379,7 +379,7 @@ void UniSetObject::push( const TransportMessage& tm )
termWaiting
();
}
// ------------------------------------------------------------------------------------------
nlohmann
::
json
UniSetObject
::
getData
()
nlohmann
::
json
UniSetObject
::
getData
(
const
Poco
::
URI
::
QueryParameters
&
p
)
{
nlohmann
::
json
jdata
;
jdata
[
"name"
]
=
myname
;
...
...
tests/UHttpTest/uhttp-test.cc
View file @
3d0492dc
...
...
@@ -12,10 +12,13 @@ class UTestSupplier:
UTestSupplier
(){}
virtual
~
UTestSupplier
(){}
virtual
nlohmann
::
json
getData
()
override
virtual
nlohmann
::
json
getData
(
const
Poco
::
URI
::
QueryParameters
&
params
)
override
{
nlohmann
::
json
j
;
for
(
const
auto
&
p
:
params
)
j
[
p
.
first
]
=
p
.
second
;
j
[
"test"
]
=
42
;
return
j
;
}
...
...
@@ -29,9 +32,9 @@ class UTestRequestRegistry:
virtual
~
UTestRequestRegistry
(){}
virtual
nlohmann
::
json
getDataByName
(
const
std
::
string
&
name
)
override
virtual
nlohmann
::
json
getDataByName
(
const
std
::
string
&
name
,
const
Poco
::
URI
::
QueryParameters
&
p
)
override
{
nlohmann
::
json
j
=
sup
.
getData
();
nlohmann
::
json
j
=
sup
.
getData
(
p
);
j
[
"name"
]
=
name
;
return
j
;
}
...
...
@@ -51,6 +54,8 @@ int main(int argc, const char** argv)
auto
http
=
make_shared
<
UHttp
::
UHttpServer
>
(
ireg
,
"localhost"
,
5555
);
http
->
log
()
->
level
(
Debug
::
ANY
);
cout
<<
"start http test server localhost:5555"
<<
endl
;
http
->
start
();
pause
();
http
->
stop
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment