Refactored checkFresh
This commit is contained in:
@@ -4,7 +4,7 @@ import javax.inject.*
|
||||
import play.api.*
|
||||
import play.api.mvc.*
|
||||
import authentication.{AuthenticatedAction, AuthenticatedRequest}
|
||||
import caching.{Etagable, checkFresh}
|
||||
import caching.{Etagable, CheckFresh}
|
||||
import models.User
|
||||
import play.api.libs.json.Json
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.Base64
|
||||
@Singleton
|
||||
class HomeController @Inject()(val controllerComponents: ControllerComponents,
|
||||
authenticatedAction: AuthenticatedAction)
|
||||
extends BaseController with Logging {
|
||||
extends BaseController with Logging with CheckFresh {
|
||||
|
||||
/**
|
||||
* Create an Action to render an HTML page.
|
||||
@@ -35,7 +35,7 @@ class HomeController @Inject()(val controllerComponents: ControllerComponents,
|
||||
|
||||
def userData = authenticatedAction { implicit request: AuthenticatedRequest[AnyContent] =>
|
||||
val user = request.user
|
||||
request.checkFresh(user) {
|
||||
checkFresh(user) {
|
||||
// TODO: put the max-age somewhere into config
|
||||
Ok(Json.toJson(user)).withHeaders("Etag" -> user.etag, "Cache-Control" -> "private, max-age=15, must-revalidate")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user