Skip to content

Commit

Permalink
fix: crash if api url regexp compile failed
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangxu19830126 committed Jan 17, 2018
1 parent ac37d32 commit ba3a810
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/pb/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package pb

import (
"fmt"
"regexp"

"github.com/fagongzi/gateway/pkg/pb/metapb"
)
Expand Down Expand Up @@ -55,5 +56,9 @@ func ValidateAPI(value *metapb.API) error {
return fmt.Errorf("missing http method")
}

if _, err := regexp.Compile(value.URLPattern); err != nil {
return err
}

return nil
}

0 comments on commit ba3a810

Please sign in to comment.