mirror of
https://codeberg.org/video-prize-ranch/rimgo.git
synced 2026-03-02 20:29:28 +00:00
add protocol to cache key (#241)
fixes #240 Reviewed-on: https://codeberg.org/rimgo/rimgo/pulls/241 Reviewed-by: video-prize-ranch <video-prize-ranch@noreply.codeberg.org> Co-authored-by: orangix <uleo8b8g@anonaddy.me> Co-committed-by: orangix <uleo8b8g@anonaddy.me>
This commit is contained in:
committed by
video-prize-ranch
parent
107a45e58b
commit
e8ed026962
4
main.go
4
main.go
@@ -11,13 +11,13 @@ import (
|
|||||||
"codeberg.org/rimgo/rimgo/static"
|
"codeberg.org/rimgo/rimgo/static"
|
||||||
"codeberg.org/rimgo/rimgo/utils"
|
"codeberg.org/rimgo/rimgo/utils"
|
||||||
"codeberg.org/rimgo/rimgo/views"
|
"codeberg.org/rimgo/rimgo/views"
|
||||||
"github.com/mailgun/raymond/v2"
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"github.com/gofiber/fiber/v2/middleware/cache"
|
"github.com/gofiber/fiber/v2/middleware/cache"
|
||||||
"github.com/gofiber/fiber/v2/middleware/filesystem"
|
"github.com/gofiber/fiber/v2/middleware/filesystem"
|
||||||
"github.com/gofiber/fiber/v2/middleware/recover"
|
"github.com/gofiber/fiber/v2/middleware/recover"
|
||||||
"github.com/gofiber/template/handlebars/v2"
|
"github.com/gofiber/template/handlebars/v2"
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
|
"github.com/mailgun/raymond/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -96,7 +96,7 @@ func main() {
|
|||||||
Expiration: 30 * time.Minute,
|
Expiration: 30 * time.Minute,
|
||||||
MaxBytes: 25000000,
|
MaxBytes: 25000000,
|
||||||
KeyGenerator: func(c *fiber.Ctx) string {
|
KeyGenerator: func(c *fiber.Ctx) string {
|
||||||
return c.OriginalURL()
|
return utils.GetInstanceProtocol(c) + " " + c.OriginalURL()
|
||||||
},
|
},
|
||||||
CacheControl: true,
|
CacheControl: true,
|
||||||
StoreResponseHeaders: true,
|
StoreResponseHeaders: true,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package utils
|
|||||||
|
|
||||||
import "github.com/gofiber/fiber/v2"
|
import "github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
func GetInstanceUrl(c *fiber.Ctx) string {
|
func GetInstanceProtocol(c *fiber.Ctx) string {
|
||||||
proto := "https"
|
proto := "https"
|
||||||
if !Config.Secure {
|
if !Config.Secure {
|
||||||
proto = "http"
|
proto = "http"
|
||||||
@@ -10,5 +10,9 @@ func GetInstanceUrl(c *fiber.Ctx) string {
|
|||||||
if Config.ProtocolDetection {
|
if Config.ProtocolDetection {
|
||||||
proto = c.Get("X-Forwarded-Proto", proto)
|
proto = c.Get("X-Forwarded-Proto", proto)
|
||||||
}
|
}
|
||||||
return proto + "://" + c.Hostname()
|
return proto
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetInstanceUrl(c *fiber.Ctx) string {
|
||||||
|
return GetInstanceProtocol(c) + "://" + c.Hostname()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user