mirror of
https://github.com/tgdrive/teldrive.git
synced 2025-01-10 01:02:01 +08:00
21 lines
453 B
Go
21 lines
453 B
Go
|
package middleware
|
||
|
|
||
|
import (
|
||
|
"time"
|
||
|
|
||
|
"github.com/divyam234/cors"
|
||
|
"github.com/gin-gonic/gin"
|
||
|
)
|
||
|
|
||
|
func Cors() gin.HandlerFunc {
|
||
|
return cors.New(cors.Config{
|
||
|
AllowMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"},
|
||
|
AllowHeaders: []string{"Authorization", "Content-Length", "Content-Type"},
|
||
|
AllowCredentials: true,
|
||
|
AllowOriginFunc: func(origin string) bool {
|
||
|
return true
|
||
|
},
|
||
|
MaxAge: 12 * time.Hour,
|
||
|
})
|
||
|
}
|