This commit is contained in:
parent
a5895af113
commit
c90bb1cd84
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user