imjoey commented on a change in pull request #1289:
URL: https://github.com/apache/apisix-dashboard/pull/1289#discussion_r556976356
##########
File path: api/internal/handler/route/route.go
##########
@@ -392,16 +398,14 @@ func (h *Handler) Update(c droplet.Context) (interface{},
error) {
script := &entity.Script{}
script.ID = input.ID
script.Script = input.Script
- //to lua
+ // Explicitly to lua if input script is of the map type,
otherwise
+ // it will always represent a piece of lua code of the string
type.
var err error
- scriptConf, ok := input.Script.(map[string]interface{})
- if !ok {
- return &data.SpecCodeResponse{StatusCode:
http.StatusBadRequest},
- fmt.Errorf("invalid `script`")
- }
- input.Route.Script, err = generateLuaCode(scriptConf)
- if err != nil {
- return &data.SpecCodeResponse{StatusCode:
http.StatusInternalServerError}, err
+ if scriptConf, ok := input.Script.(map[string]interface{}); ok {
+ input.Route.Script, err = generateLuaCode(scriptConf)
+ if err != nil {
+ return &data.SpecCodeResponse{StatusCode:
http.StatusInternalServerError}, err
+ }
Review comment:
@starsz thanks for your advice. PR renewed and an additional validation
check was added. Looking forward to your feedback. Much appreciated.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]