diff --git a/application.go b/application.go index 8dcd786..62feea7 100644 --- a/application.go +++ b/application.go @@ -45,13 +45,25 @@ func (this *Application) Run(router Router) { this.Router = router //重新设置MethodRouter//直达路由 this.MethodRouter=MethodRouter{} - + modeRouterStrict:=true + if this.Config.Get("modeRouterStrict").(bool)==false{ + modeRouterStrict=false + } if router!=nil{ for pk,pv:= range router{ + if !modeRouterStrict{ + pk=strings.ToLower(pk) + } if pv!=nil{ for ck,cv:=range pv{ + if !modeRouterStrict{ + ck=strings.ToLower(ck) + } if cv!=nil{ for mk,mv:=range cv{ + if !modeRouterStrict{ + mk=strings.ToLower(mk) + } this.MethodRouter["/"+pk+"/"+ck+"/"+mk]=mv } } @@ -226,6 +238,8 @@ func (this *Application) urlSer(url string) (string, []string) { } //访问 + + func (this *Application) handler(w http.ResponseWriter, req *http.Request) { o, s := this.urlSer(req.RequestURI) @@ -296,9 +310,16 @@ func (this *Application) handler(w http.ResponseWriter, req *http.Request) { // } // //} + //验证接口严格模式 + modeRouterStrict:=this.Config.Get("modeRouterStrict").(bool) + tempHandlerStr:=context.HandlerStr + if !modeRouterStrict{ + tempHandlerStr=strings.ToLower(tempHandlerStr) + } - if this.MethodRouter[context.HandlerStr]!=nil{ - this.MethodRouter[context.HandlerStr](&context) + //执行接口 + if this.MethodRouter[tempHandlerStr]!=nil{ + this.MethodRouter[tempHandlerStr](&context) context.View() return } diff --git a/var.go b/var.go index 91dc555..9a1df9b 100644 --- a/var.go +++ b/var.go @@ -22,4 +22,5 @@ var Config = Map{ "sessionName": "HOTIME", "error": Map{}, "debug":1,//debug 0关闭1开启 + "modeRouterStrict":false,//路由严格模式/a/b/c }