55import com .fasterxml .jackson .databind .ObjectMapper ;
66import com .fasterxml .jackson .databind .SerializationFeature ;
77import com .fasterxml .jackson .datatype .jsr310 .JavaTimeModule ;
8- import com .google .common .net .HttpHeaders ;
98import dev .openfeature .contrib .providers .gofeatureflag .EvaluationResponse ;
109import dev .openfeature .contrib .providers .gofeatureflag .GoFeatureFlagProviderOptions ;
1110import dev .openfeature .contrib .providers .gofeatureflag .bean .ConfigurationChange ;
@@ -60,6 +59,11 @@ public class GoFeatureFlagController {
6059 .configure (DeserializationFeature .FAIL_ON_UNKNOWN_PROPERTIES , false );
6160 private static final String BEARER_TOKEN = "Bearer " ;
6261
62+ private static final String HTTP_HEADER_CONTENT_TYPE = "Content-Type" ;
63+ private static final String HTTP_HEADER_AUTHORIZATION = "Authorization" ;
64+ private static final String HTTP_HEADER_ETAG = "ETag" ;
65+ private static final String HTTP_HEADER_IF_NONE_MATCH = "If-None-Match" ;
66+
6367 /**
6468 * apiKey contains the token to use while calling GO Feature Flag relay proxy.
6569 */
@@ -137,13 +141,13 @@ public <T> EvaluationResponse<T> evaluateFlag(
137141
138142 Request .Builder reqBuilder = new Request .Builder ()
139143 .url (url )
140- .addHeader (HttpHeaders . CONTENT_TYPE , APPLICATION_JSON )
144+ .addHeader (HTTP_HEADER_CONTENT_TYPE , APPLICATION_JSON )
141145 .post (RequestBody .create (
142146 requestMapper .writeValueAsBytes (goffRequest ),
143147 MediaType .get ("application/json; charset=utf-8" )));
144148
145149 if (this .apiKey != null && !this .apiKey .isEmpty ()) {
146- reqBuilder .addHeader (HttpHeaders . AUTHORIZATION , BEARER_TOKEN + this .apiKey );
150+ reqBuilder .addHeader (HTTP_HEADER_AUTHORIZATION , BEARER_TOKEN + this .apiKey );
147151 }
148152
149153 try (Response response = this .httpClient .newCall (reqBuilder .build ()).execute ()) {
@@ -216,13 +220,13 @@ public void sendEventToDataCollector(List<Event> eventsList) {
216220
217221 Request .Builder reqBuilder = new Request .Builder ()
218222 .url (url )
219- .addHeader (HttpHeaders . CONTENT_TYPE , APPLICATION_JSON )
223+ .addHeader (HTTP_HEADER_CONTENT_TYPE , APPLICATION_JSON )
220224 .post (RequestBody .create (
221225 requestMapper .writeValueAsBytes (events ),
222226 MediaType .get ("application/json; charset=utf-8" )));
223227
224228 if (this .apiKey != null && !this .apiKey .isEmpty ()) {
225- reqBuilder .addHeader (HttpHeaders . AUTHORIZATION , BEARER_TOKEN + this .apiKey );
229+ reqBuilder .addHeader (HTTP_HEADER_AUTHORIZATION , BEARER_TOKEN + this .apiKey );
226230 }
227231
228232 try (Response response = this .httpClient .newCall (reqBuilder .build ()).execute ()) {
@@ -259,14 +263,14 @@ public ConfigurationChange configurationHasChanged() throws GoFeatureFlagExcepti
259263
260264 Request .Builder reqBuilder = new Request .Builder ()
261265 .url (url )
262- .addHeader (HttpHeaders . CONTENT_TYPE , APPLICATION_JSON )
266+ .addHeader (HTTP_HEADER_CONTENT_TYPE , APPLICATION_JSON )
263267 .get ();
264268
265269 if (this .etag != null && !this .etag .isEmpty ()) {
266- reqBuilder .addHeader (HttpHeaders . IF_NONE_MATCH , this .etag );
270+ reqBuilder .addHeader (HTTP_HEADER_IF_NONE_MATCH , this .etag );
267271 }
268272 if (this .apiKey != null && !this .apiKey .isEmpty ()) {
269- reqBuilder .addHeader (HttpHeaders . AUTHORIZATION , BEARER_TOKEN + this .apiKey );
273+ reqBuilder .addHeader (HTTP_HEADER_AUTHORIZATION , BEARER_TOKEN + this .apiKey );
270274 }
271275
272276 try (Response response = this .httpClient .newCall (reqBuilder .build ()).execute ()) {
@@ -283,7 +287,7 @@ public ConfigurationChange configurationHasChanged() throws GoFeatureFlagExcepti
283287 }
284288
285289 boolean isInitialConfiguration = this .etag == null ;
286- this .etag = response .header (HttpHeaders . ETAG );
290+ this .etag = response .header (HTTP_HEADER_ETAG );
287291 return isInitialConfiguration
288292 ? ConfigurationChange .FLAG_CONFIGURATION_INITIALIZED
289293 : ConfigurationChange .FLAG_CONFIGURATION_UPDATED ;
0 commit comments