/Gokhan Secret
Created
June 18, 2018 15:26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Provider | |
public class LogFilter implements ContainerRequestFilter, ContainerResponseFilter { | |
@Override | |
public void filter(ContainerRequestContext reqContext) throws IOException { | |
System.out.println("-- req info --"); | |
log(reqContext.getUriInfo(), reqContext.getHeaders()); | |
} | |
@Override | |
public void filter(ContainerRequestContext reqContext, | |
ContainerResponseContext resContext) throws IOException { | |
System.out.println("-- res info --"); | |
log(reqContext.getUriInfo(), resContext.getHeaders()); | |
} | |
private void log(UriInfo uriInfo, MultivaluedMap<String, ?> headers) { | |
System.out.println("Path: " + uriInfo.getPath()); | |
headers.entrySet().forEach(h -> System.out.println(h.getKey() + ": " + h.getValue())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment