Skip to content

Commit

Permalink
Merge pull request #83 from pinguo-yangbing/master
Browse files Browse the repository at this point in the history
cmd 不区分大小写
  • Loading branch information
pinguo-yangbing authored Sep 30, 2020
2 parents c69e5a4 + 53e2101 commit 68a103b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
8 changes: 4 additions & 4 deletions init.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var (
"env": {Name: "env", Usage: "set running env (optional), eg. --env=online"},
"cmd": {Name: "cmd", Usage: "set running cmd (optional), eg. --cmd=/foo/bar"},
"base": {Name: "base", Usage: "set base path (optional), eg. --base=/base/path"},
"help": {Name: "help", Usage: "Displays a list of CMD controllers used (optional), eg. --help=1"},
"help": {Name: "help",DefValue:"1", Usage: "Displays a list of CMD controllers used (optional), eg. --help=1"},
}
)

Expand Down Expand Up @@ -176,22 +176,22 @@ func cmdList(path string) {
if !methodV.IsValid() {
return ""
}

methodV.Call(nil)
return flagParams(false)
}

if path != "" {
path = util.CleanPath(path)
path = strings.ToLower(util.CleanPath(path))
}

for uri, v := range list {
// fmt.Println("path", path,"uri",uri)

if path != "" && path != uri {
if path != "" && path != strings.ToLower(uri) {
continue
}


paramsStr:= showParams(uri)
fmt.Println(" --cmd=" + uri + " \t" + v.desc)
if paramsStr != "" {
Expand Down
17 changes: 13 additions & 4 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type Handler struct {
desc string
}

func (h *Handler) SetDesc(v string){
func (h *Handler) SetDesc(v string) {
h.desc = v
}

Expand All @@ -86,7 +86,6 @@ func (r *Router) SetErrorController(v string) {
r.errorController = v
}


// SetRules set rule list, format: `^/api/user/(\d+)$ => /api/user`
func (r *Router) SetRules(rules []interface{}) {
for _, v := range rules {
Expand Down Expand Up @@ -254,11 +253,21 @@ func (r *Router) Handler(path string) *Handler {
if handler, ok := r.webHandlers[path]; ok {
return handler
}
} else {
if handler, ok := r.cmdHandlers[path]; ok {

return nil
}

if handler, ok := r.cmdHandlers[path]; ok {
return handler
}

path = strings.ToLower(path)
for kPath, handler := range r.cmdHandlers {
if strings.ToLower(kPath) == path {
return handler
}
}

return nil
}

Expand Down

0 comments on commit 68a103b

Please sign in to comment.