Socialify

Folder ..

Viewing template.go
19 lines (14 loc) • 329.0 B

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
package middleware

import (
	"context"

	"github.com/gofiber/fiber/v2"
)

type contextKey string

const fiberCtxKey contextKey = "fiberCtx"

func TemplateContextMiddleware() fiber.Handler {
	return func(c *fiber.Ctx) error {
		ctx := context.WithValue(c.Context(), fiberCtxKey, c)
		c.SetUserContext(ctx)
		return c.Next()
	}
}