Skip to content

Commit

Permalink
don't compute Context.minimal(req) twice
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Feb 19, 2025
1 parent 8255cc1 commit 7138d3e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/http/RequestContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ trait RequestContext(using Executor):

def InEmbedContext[A](f: EmbedContext ?=> A)(using ctx: Context): A =
if !env.net.isProd then env.web.manifest.update()
f(using EmbedContext(ctx.req))
f(using EmbedContext(ctx))

private def makeUserContext(req: RequestHeader): Fu[LoginContext] =
env.security.api
Expand Down
6 changes: 3 additions & 3 deletions modules/api/src/main/Context.scala
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ final class EmbedContext(val ctx: Context, val bg: String, val nonce: Nonce):

object EmbedContext:
given (using config: EmbedContext): Lang = config.lang
def apply(req: RequestHeader): EmbedContext = new EmbedContext(
Context.minimal(req),
bg = req.queryString.get("bg").flatMap(_.headOption).filterNot("auto".==) | "system",
def apply(ctx: Context): EmbedContext = new EmbedContext(
ctx,
bg = ctx.req.queryString.get("bg").flatMap(_.headOption).filterNot("auto".==) | "system",
nonce = Nonce.random
)

0 comments on commit 7138d3e

Please sign in to comment.