Search in sources :

Example 1 with Before

use of play.mvc.Before in project play-cookbook by spinscale.

the class Application method checkAuth.

@Before(priority = 1, unless = { "createTicket", "quotes", "thing" })
public static void checkAuth() {
    Header ticket = request.headers.get("x-authorization");
    if (ticket == null) {
        error("Please provide a ticket");
    }
    String cacheTicket = Cache.get("ticket:" + ticket.value(), String.class);
    if (cacheTicket == null) {
        error("Please renew your ticket");
    }
    Cache.set("ticket:" + ticket.value(), cacheTicket, "5min");
}
Also used : Header(play.mvc.Http.Header) Before(play.mvc.Before)

Aggregations

Before (play.mvc.Before)1 Header (play.mvc.Http.Header)1