Slide 8
Slide 8 text
FILTER
• ΞϓϦέʔγϣϯͱಠཱ͍ͯ͠ΔɺαʔϏεͱ
߹Ͱ͖ΔσίϨʔλʔతͳͷ
• ྫɿfilter , timeOut, retries, authentication
class HeaderFilter extends SimpleFilter[HttpRequest, HttpResponse] {
def apply(request: HttpRequest, service: Service[HttpRequest,
HttpResponse]) = {
// Look for a X-Request-ID header and add one if missing.
val id = request.getHeader("X-Request-ID")
if (id == null) {
request.setHeader("X-Request-ID",
UUID.randomUUID().toString)
}
// Add X-Processes to the response.
service(request).onSuccess(r => {
r.addHeader("X-Processed", "TRUE")
})
}
}