v1.3.5: add CORS whitelist support (f.CORS) covering /cell and all custom routes

This commit is contained in:
2026-09-09 11:31:22 +08:00
parent cfecbff8f8
commit a4993502bc
6 changed files with 236 additions and 6 deletions
+5
View File
@@ -18,6 +18,11 @@ func (f *Fun) handle(fastCtx *fasthttp.RequestCtx) {
ctx := &Ctx{RequestCtx: fastCtx}
defer f.handlePanic(ctx)
// CORS 置于路由之前:预检请求在此直接应答,实际请求附加跨域头后继续正常分发
if f.handleCors(fastCtx) {
return
}
method, path := string(fastCtx.Method()), string(fastCtx.Path())
if r, ok := f.routes[method+" "+path]; ok {
f.handleRoute(fastCtx, r, "")