Browse Source

reply 401 on wrong API key

pull/1/head
Ulysse Goarant 4 years ago
parent
commit
bff46606e4
  1. 9
      src/main/java/org/sebi/incident/IncidentResource.java

9
src/main/java/org/sebi/incident/IncidentResource.java

@ -1,10 +1,9 @@
package org.sebi.incident;
import java.util.List;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
import org.eclipse.microprofile.config.inject.ConfigProperty;
@ -19,11 +18,11 @@ public class IncidentResource {
@GET
public List<Incident> getIncidents(@QueryParam("api_key") String apiKey){
public Response getIncidents(@QueryParam("api_key") String apiKey){
if(this.apiKey.equals(apiKey)){
return Incident.listAll();
return Response.ok(Incident.listAll()).build();
}
return null;
return Response.status(Response.Status.UNAUTHORIZED).build();
}
@GET

Loading…
Cancel
Save