Ratpacked: Add Response Time To Response Header - DZone Java
Ratpacked: Add Response Time To Response Header Learn the two methods to add a response time to the response header. by Like (1) Comment (0) Ratpack has the class X-Response-Time to the response. The value is the time spent in code from when the request comes in and the response is sent out. ResponseTimer is a handler we can add in our application. Alternatively we can use the static method decorator to get a handler decorator. With a handler decorator we can use the registry to add handler logic in our application. First we use the @Grab("io.ratpack:ratpack-groovy:1.1.1") import ratpack.handling.ResponseTimer import static ratpack.groovy.Groovy.ratpack ratpack { handlers { // Add ResponseTimer for // all requests. all(new ResponseTimer()) get { render "Ratpack rocks!" } } } We get the same result if we add the handler decorator via the registry: @Grab("io.ratpack:ratpack-groovy:1.1.1") import ratpack.handling.ResponseTimer import static ratpack.groovy.Groovy.Read full article from Ratpacked: Add Response Time To Response Header - DZone Java
No comments:
Post a Comment