Skip to content

Commit

Permalink
Add health indicator (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
dharmendrak authored and sabahirfan committed Dec 14, 2017
1 parent 7fc2fbe commit 85e6d7d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group 'uk.gov.hmcts.reform'
version '0.0.5'
version '0.0.6'

checkstyle {
maxWarnings = 0
Expand Down Expand Up @@ -119,8 +119,8 @@ ext {
}

dependencies {
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-feign'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-feign'
compile group: 'com.netflix.feign', name: 'feign-jackson', version: '8.18.0'
compile group: 'com.google.guava', name: 'guava', version: '23.0'
compile group: 'com.warrenstrange', name: 'googleauth', version: '1.1.2'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package uk.gov.hmcts.reform.authorisation;

import org.springframework.cloud.netflix.feign.EnableFeignClients;
import feign.codec.Decoder;
import feign.jackson.JacksonDecoder;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
Expand All @@ -14,8 +18,8 @@
import static org.springframework.http.HttpHeaders.CONTENT_TYPE;
import static org.springframework.http.MediaType.APPLICATION_JSON_UTF8_VALUE;

@EnableFeignClients
@FeignClient(name = "idam-s2s-auth", url = "${idam.s2s-auth.url}")
@FeignClient(name = "idam-s2s-auth", url = "${idam.s2s-auth.url}",
configuration = ServiceAuthorisationApi.ServiceAuthConfiguration.class)
public interface ServiceAuthorisationApi {
@PostMapping(value = "/lease")
String serviceToken(@RequestParam("microservice") final String microservice,
Expand All @@ -31,4 +35,14 @@ void authorise(@RequestHeader(AUTHORIZATION) final String authHeader,
headers = CONTENT_TYPE + "=" + APPLICATION_JSON_UTF8_VALUE
)
InternalHealth health();


class ServiceAuthConfiguration {
@Bean
@Primary
@Scope("prototype")
Decoder feignDecoder() {
return new JacksonDecoder();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
package uk.gov.hmcts.reform.authorisation.healthcheck;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.boot.actuate.health.Status;

import java.util.Map;

@JsonIgnoreProperties(ignoreUnknown = true)
public class InternalHealth {
private final Status status;
private final Map<String, Object> details;

@JsonCreator
public InternalHealth(
@JsonProperty("status") Status status,
@JsonProperty("details") Map<String, Object> details
@JsonProperty("status") Status status
) {
this.status = status;
this.details = details;
}

public Status getStatus() {
return status;
}

public Map<String, Object> getDetails() {
return details;
}
}

0 comments on commit 85e6d7d

Please sign in to comment.