Skip to content

Commit

Permalink
Fix: Return 404 response when Lua script is not found
Browse files Browse the repository at this point in the history
Previously, the system returned a generic error when a Lua script for a specific hook was missing. This update sends a 404 status with a JSON error response, improving clarity and aligning with standard HTTP practices.

Signed-off-by: Christian Roessner <[email protected]>
  • Loading branch information
Christian Roessner committed Jan 13, 2025
1 parent 850fe38 commit 9c67a41
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/lualib/hook/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,9 @@ func runLuaCustomWrapper(ctx *gin.Context, registerDynamicLoader func(*lua.LStat
hook := ctx.Param("hook")

if script = customLocation.GetScript(hook, ctx.Request.Method); script == nil {
return gin.H{}, fmt.Errorf("lua script for location '%s' not found", hook)
ctx.AbortWithStatusJSON(http.StatusNotFound, gin.H{"error": "lua script for location '" + hook + "' not found", "guid": guid})

return nil, nil
}

luaCtx, luaCancel := context.WithTimeout(ctx, viper.GetDuration("lua_script_timeout")*time.Second)
Expand Down

0 comments on commit 9c67a41

Please sign in to comment.