Refactored checkFresh

This commit is contained in:
2026-09-17 15:08:38 +03:00
parent 621fcf90fa
commit e144a7f3c0
2 changed files with 9 additions and 9 deletions
+3 -3
View File
@@ -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")
}