Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-boot-admin
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
spring-boot-admin
Commits
81168636
Commit
81168636
authored
Feb 20, 2018
by
Johannes Edmeier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add CompositeHttpHeadersProvider as primary header
... to support multiple HttpHeadersProviders
parent
4a936c45
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
106 additions
and
1 deletion
+106
-1
AdminServerAutoConfiguration.java
...oot/admin/server/config/AdminServerAutoConfiguration.java
+13
-1
CompositeHttpHeadersProvider.java
...admin/server/web/client/CompositeHttpHeadersProvider.java
+38
-0
CompositeHttpHeadersProviderTest.java
...n/server/web/client/CompositeHttpHeadersProviderTest.java
+55
-0
No files found.
spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/config/AdminServerAutoConfiguration.java
View file @
81168636
...
...
@@ -34,9 +34,11 @@ import de.codecentric.boot.admin.server.services.endpoints.ChainingStrategy;
import
de.codecentric.boot.admin.server.services.endpoints.ProbeEndpointsStrategy
;
import
de.codecentric.boot.admin.server.services.endpoints.QueryIndexEndpointStrategy
;
import
de.codecentric.boot.admin.server.web.client.BasicAuthHttpHeaderProvider
;
import
de.codecentric.boot.admin.server.web.client.CompositeHttpHeadersProvider
;
import
de.codecentric.boot.admin.server.web.client.HttpHeadersProvider
;
import
de.codecentric.boot.admin.server.web.client.InstanceWebClient
;
import
java.util.Collection
;
import
org.reactivestreams.Publisher
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
...
...
@@ -44,6 +46,8 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.core.annotation.Order
;
@Configuration
@ConditionalOnBean
(
AdminServerMarkerConfiguration
.
Marker
.
class
)
...
...
@@ -70,8 +74,16 @@ public class AdminServerAutoConfiguration {
}
@Bean
@Primary
@ConditionalOnMissingBean
public
HttpHeadersProvider
httpHeadersProvider
()
{
public
CompositeHttpHeadersProvider
httpHeadersProvider
(
Collection
<
HttpHeadersProvider
>
delegates
)
{
return
new
CompositeHttpHeadersProvider
(
delegates
);
}
@Bean
@Order
(
0
)
@ConditionalOnMissingBean
public
BasicAuthHttpHeaderProvider
basicAuthHttpHeadersProvider
()
{
return
new
BasicAuthHttpHeaderProvider
();
}
...
...
spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/web/client/CompositeHttpHeadersProvider.java
0 → 100644
View file @
81168636
/*
* Copyright 2014-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
de
.
codecentric
.
boot
.
admin
.
server
.
web
.
client
;
import
de.codecentric.boot.admin.server.domain.entities.Instance
;
import
java.util.Collection
;
import
org.springframework.http.HttpHeaders
;
public
class
CompositeHttpHeadersProvider
implements
HttpHeadersProvider
{
private
final
Collection
<
HttpHeadersProvider
>
delegates
;
public
CompositeHttpHeadersProvider
(
Collection
<
HttpHeadersProvider
>
delegates
)
{
this
.
delegates
=
delegates
;
}
@Override
public
HttpHeaders
getHeaders
(
Instance
instance
)
{
HttpHeaders
headers
=
new
HttpHeaders
();
delegates
.
forEach
(
delegate
->
headers
.
addAll
(
delegate
.
getHeaders
(
instance
)));
return
headers
;
}
}
spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/web/client/CompositeHttpHeadersProviderTest.java
0 → 100644
View file @
81168636
/*
* Copyright 2014-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
de
.
codecentric
.
boot
.
admin
.
server
.
web
.
client
;
import
org.junit.Test
;
import
org.springframework.http.HttpHeaders
;
import
static
java
.
util
.
Arrays
.
asList
;
import
static
java
.
util
.
Collections
.
emptyList
;
import
static
java
.
util
.
Collections
.
singletonList
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
public
class
CompositeHttpHeadersProviderTest
{
@Test
public
void
should_return_all_headers
()
{
HttpHeadersProvider
provider
=
new
CompositeHttpHeadersProvider
(
asList
(
i
->
{
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
set
(
"a"
,
"1"
);
headers
.
set
(
"b"
,
"2-a"
);
return
headers
;
},
i
->
{
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
set
(
"b"
,
"2-b"
);
headers
.
set
(
"c"
,
"3"
);
return
headers
;
}));
HttpHeaders
headers
=
provider
.
getHeaders
(
null
);
assertThat
(
headers
.
get
(
"a"
)).
isEqualTo
(
singletonList
(
"1"
));
assertThat
(
headers
.
get
(
"b"
)).
isEqualTo
(
asList
(
"2-a"
,
"2-b"
));
assertThat
(
headers
.
get
(
"c"
)).
isEqualTo
(
singletonList
(
"3"
));
}
@Test
public
void
should_return_empty_headers
()
{
HttpHeadersProvider
provider
=
new
CompositeHttpHeadersProvider
(
emptyList
());
HttpHeaders
headers
=
provider
.
getHeaders
(
null
);
assertThat
(
headers
.
size
()).
isEqualTo
(
0
);
}
}
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