Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
ipgallery.common.java
/
microservice
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Registry
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
30bcab95
authored
Jun 07, 2017
by
amir
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add getHeaders in IRequest
parent
bc7a21f9
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
40 additions
and
3 deletions
build.gradle
doc/todo.txt
src/main/java/microservice/io/iface/IRequest.java
src/main/java/microservice/io/impl/IRequestMBIImpl.java
src/main/java/microservice/io/impl/IRequestRestImpl.java
src/main/java/microservice/services/protocol/zmq/RestImpl.java
src/test/java/microservice/TestMicroserviceApp.java
build.gradle
View file @
30bcab95
group
'com.ipgallery.common'
version
'2.0.0'
version
'2.0.0
-services
'
apply
plugin:
'java'
apply
plugin:
'maven-publish'
...
...
doc/todo.txt
View file @
30bcab95
...
...
@@ -22,4 +22,6 @@
// });
- add static page for monitor metrics that calls http://localhost:32000/_mon/_stat?viewType=list
periodically via jquery and display the metrics in a table
\ No newline at end of file
- periodically via jquery and display the metrics in a table
- Add zipkin to trace and monitor requests across microservices
\ No newline at end of file
src/main/java/microservice/io/iface/IRequest.java
View file @
30bcab95
...
...
@@ -2,6 +2,7 @@ package microservice.io.iface;
import
java.io.InputStream
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Consumer
;
public
interface
IRequest
...
...
@@ -26,6 +27,13 @@ public interface IRequest
*/
List
<
String
>
getHeader
(
String
headerName
);
/**
* return map of the request headers name with list of values
* since there can multiple headers with the same name
* @return
*/
Map
<
String
,
List
<
String
>>
getHeaders
();
public
boolean
startAsync
(
Runnable
asyncFunc
);
}
src/main/java/microservice/io/impl/IRequestMBIImpl.java
View file @
30bcab95
...
...
@@ -3,6 +3,7 @@ package microservice.io.impl;
import
java.io.ByteArrayInputStream
;
import
java.io.InputStream
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Consumer
;
//import com.sun.xml.internal.ws.api.message.stream.InputStreamMessage;
...
...
@@ -61,6 +62,11 @@ public class IRequestMBIImpl implements IRequest
}
@Override
public
Map
<
String
,
List
<
String
>>
getHeaders
()
{
return
null
;
}
@Override
public
boolean
startAsync
(
Runnable
asyncFunc
)
{
return
false
;
}
...
...
src/main/java/microservice/io/impl/IRequestRestImpl.java
View file @
30bcab95
package
microservice
.
io
.
impl
;
import
java.io.InputStream
;
import
java.util.Arrays
;
import
java.util.Deque
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Consumer
;
import
io.undertow.server.HttpServerExchange
;
import
io.undertow.util.HeaderValues
;
import
microservice.io.iface.IRequest
;
public
class
IRequestRestImpl
implements
IRequest
...
...
@@ -45,6 +50,15 @@ public class IRequestRestImpl implements IRequest
}
@Override
public
Map
<
String
,
List
<
String
>>
getHeaders
(){
Map
<
String
,
List
<
String
>>
headersDeque
=
new
HashMap
<>(
exchange
.
getRequestHeaders
().
size
());
for
(
HeaderValues
headerValues
:
exchange
.
getRequestHeaders
()){
headersDeque
.
put
(
headerValues
.
getHeaderName
().
toString
(),
Arrays
.
asList
(
headerValues
.
toArray
()));
}
return
headersDeque
;
}
@Override
public
List
<
String
>
getHeader
(
String
headerName
)
{
return
exchange
.
getRequestHeaders
().
get
(
headerName
);
}
...
...
src/main/java/microservice/services/protocol/zmq/RestImpl.java
View file @
30bcab95
...
...
@@ -13,6 +13,7 @@ import java.io.ByteArrayInputStream;
import
java.io.InputStream
;
import
java.nio.ByteBuffer
;
import
java.util.List
;
import
java.util.Map
;
/**
* Created by amir on 22/05/17.
...
...
@@ -52,6 +53,11 @@ public class RestImpl {
}
@Override
public
Map
<
String
,
List
<
String
>>
getHeaders
()
{
return
null
;
}
@Override
public
boolean
startAsync
(
Runnable
asyncFunc
)
{
asyncFunc
.
run
();
return
true
;
...
...
src/test/java/microservice/TestMicroserviceApp.java
View file @
30bcab95
...
...
@@ -183,6 +183,7 @@ public class TestMicroserviceApp {
ObjectNode
objectNode
=
JsonNodeFactory
.
instance
.
objectNode
();
if
(
restContext
.
pathParameters
!=
null
)
restContext
.
pathParameters
.
forEach
((
key
,
value
)
->
objectNode
.
put
(
key
,
value
));
restContext
.
request
.
getHeaders
().
forEach
((
key
,
values
)
->
objectNode
.
put
(
key
,
values
.
toString
()));
brr
.
objectNode
=
objectNode
;
restContext
.
container
.
writeObjectToResponse
(
restContext
.
response
,
brr
);
}
...
...
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