This commit is contained in:
cdle
2023-06-29 13:49:23 +08:00
parent b6e4c180c3
commit 7ea4710d16
10 changed files with 97 additions and 70 deletions
+15 -11
View File
@@ -134,20 +134,24 @@ func initWeb() {
c: c,
}
for _, function := range Functions {
if function.Http != nil {
path := function.Http.Path
method := function.Http.Method
if c.Request.URL.Path == path && c.Request.Method == method {
req.handled = true
function.Handle(&Faker{
Type: "*",
}, func(vm *goja.Runtime) {
vm.Set("res", res)
vm.Set("req", req)
})
if len(function.Https) != 0 {
for _, http := range function.Https {
path := http.Path
method := http.Method
if c.Request.URL.Path == path && c.Request.Method == method {
req.handled = true
function.Handle(&Faker{
Type: "*",
}, func(vm *goja.Runtime) {
vm.Set("res", res)
vm.Set("req", req)
})
goto HELL
}
}
}
}
HELL:
if req.handled {
if res.isRedirect {