2025-10-31 09:23:44 +00:00
|
|
|
package middleware
|
|
|
|
|
|
2025-10-31 10:01:06 +00:00
|
|
|
import (
|
|
|
|
|
"github.com/cloudwego/hertz/pkg/app"
|
|
|
|
|
"weather_and_earthquake/internal/config"
|
|
|
|
|
)
|
2025-10-31 09:23:44 +00:00
|
|
|
import "context"
|
|
|
|
|
|
2025-10-31 10:01:06 +00:00
|
|
|
var Apps *config.Apps
|
|
|
|
|
|
2025-10-31 09:23:44 +00:00
|
|
|
// 跨域
|
|
|
|
|
func CorsMiddleware() app.HandlerFunc {
|
|
|
|
|
return func(ctx context.Context, c *app.RequestContext) {
|
|
|
|
|
c.Response.Header.Set("Access-Control-Allow-Origin", "*")
|
|
|
|
|
c.Response.Header.Set("Access-Control-Allow-Methods", "*")
|
|
|
|
|
c.Response.Header.Set("Access-Control-Allow-Headers", "*")
|
|
|
|
|
c.Response.Header.Set("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Cache-Control, Content-Language, Content-Type")
|
|
|
|
|
c.Next(ctx)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 校验签名
|
|
|
|
|
func AuthMiddleware() app.HandlerFunc {
|
|
|
|
|
return func(ctx context.Context, c *app.RequestContext) {
|
|
|
|
|
c.Next(ctx)
|
|
|
|
|
}
|
|
|
|
|
}
|