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
e193235b
authored
Jun 07, 2017
by
amir
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add getHeaders in IRequest
parent
172c1b1e
Hide 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 @
e193235b
group
'com.ipgallery.common'
group
'com.ipgallery.common'
version
'2.0.0'
version
'2.0.0
-services
'
apply
plugin:
'java'
apply
plugin:
'java'
apply
plugin:
'maven-publish'
apply
plugin:
'maven-publish'
...
...
doc/todo.txt
View file @
e193235b
...
@@ -22,4 +22,6 @@
...
@@ -22,4 +22,6 @@
// });
// });
- add static page for monitor metrics that calls http://localhost:32000/_mon/_stat?viewType=list
- 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
- periodically via jquery and display the metrics in a table
\ No newline at end of file
- 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 @
e193235b
...
@@ -2,6 +2,7 @@ package microservice.io.iface;
...
@@ -2,6 +2,7 @@ package microservice.io.iface;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Consumer
;
import
java.util.function.Consumer
;
public
interface
IRequest
public
interface
IRequest
...
@@ -26,6 +27,13 @@ public interface IRequest
...
@@ -26,6 +27,13 @@ public interface IRequest
*/
*/
List
<
String
>
getHeader
(
String
headerName
);
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
);
public
boolean
startAsync
(
Runnable
asyncFunc
);
}
}
src/main/java/microservice/io/impl/IRequestMBIImpl.java
View file @
e193235b
...
@@ -3,6 +3,7 @@ package microservice.io.impl;
...
@@ -3,6 +3,7 @@ package microservice.io.impl;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayInputStream
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Consumer
;
import
java.util.function.Consumer
;
//import com.sun.xml.internal.ws.api.message.stream.InputStreamMessage;
//import com.sun.xml.internal.ws.api.message.stream.InputStreamMessage;
...
@@ -61,6 +62,11 @@ public class IRequestMBIImpl implements IRequest
...
@@ -61,6 +62,11 @@ public class IRequestMBIImpl implements IRequest
}
}
@Override
@Override
public
Map
<
String
,
List
<
String
>>
getHeaders
()
{
return
null
;
}
@Override
public
boolean
startAsync
(
Runnable
asyncFunc
)
{
public
boolean
startAsync
(
Runnable
asyncFunc
)
{
return
false
;
return
false
;
}
}
...
...
src/main/java/microservice/io/impl/IRequestRestImpl.java
View file @
e193235b
package
microservice
.
io
.
impl
;
package
microservice
.
io
.
impl
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.util.Arrays
;
import
java.util.Deque
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Consumer
;
import
java.util.function.Consumer
;
import
io.undertow.server.HttpServerExchange
;
import
io.undertow.server.HttpServerExchange
;
import
io.undertow.util.HeaderValues
;
import
microservice.io.iface.IRequest
;
import
microservice.io.iface.IRequest
;
public
class
IRequestRestImpl
implements
IRequest
public
class
IRequestRestImpl
implements
IRequest
...
@@ -45,6 +50,15 @@ public class IRequestRestImpl implements IRequest
...
@@ -45,6 +50,15 @@ public class IRequestRestImpl implements IRequest
}
}
@Override
@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
)
{
public
List
<
String
>
getHeader
(
String
headerName
)
{
return
exchange
.
getRequestHeaders
().
get
(
headerName
);
return
exchange
.
getRequestHeaders
().
get
(
headerName
);
}
}
...
...
src/main/java/microservice/services/protocol/zmq/RestImpl.java
View file @
e193235b
...
@@ -13,6 +13,7 @@ import java.io.ByteArrayInputStream;
...
@@ -13,6 +13,7 @@ import java.io.ByteArrayInputStream;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.nio.ByteBuffer
;
import
java.nio.ByteBuffer
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* Created by amir on 22/05/17.
* Created by amir on 22/05/17.
...
@@ -52,6 +53,11 @@ public class RestImpl {
...
@@ -52,6 +53,11 @@ public class RestImpl {
}
}
@Override
@Override
public
Map
<
String
,
List
<
String
>>
getHeaders
()
{
return
null
;
}
@Override
public
boolean
startAsync
(
Runnable
asyncFunc
)
{
public
boolean
startAsync
(
Runnable
asyncFunc
)
{
asyncFunc
.
run
();
asyncFunc
.
run
();
return
true
;
return
true
;
...
...
src/test/java/microservice/TestMicroserviceApp.java
View file @
e193235b
...
@@ -183,6 +183,7 @@ public class TestMicroserviceApp {
...
@@ -183,6 +183,7 @@ public class TestMicroserviceApp {
ObjectNode
objectNode
=
JsonNodeFactory
.
instance
.
objectNode
();
ObjectNode
objectNode
=
JsonNodeFactory
.
instance
.
objectNode
();
if
(
restContext
.
pathParameters
!=
null
)
if
(
restContext
.
pathParameters
!=
null
)
restContext
.
pathParameters
.
forEach
((
key
,
value
)
->
objectNode
.
put
(
key
,
value
));
restContext
.
pathParameters
.
forEach
((
key
,
value
)
->
objectNode
.
put
(
key
,
value
));
restContext
.
request
.
getHeaders
().
forEach
((
key
,
values
)
->
objectNode
.
put
(
key
,
values
.
toString
()));
brr
.
objectNode
=
objectNode
;
brr
.
objectNode
=
objectNode
;
restContext
.
container
.
writeObjectToResponse
(
restContext
.
response
,
brr
);
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