forked from golang/hotime
This commit is contained in:
parent
a5895af113
commit
c90bb1cd84
@ -45,13 +45,25 @@ func (this *Application) Run(router Router) {
|
|||||||
this.Router = router
|
this.Router = router
|
||||||
//重新设置MethodRouter//直达路由
|
//重新设置MethodRouter//直达路由
|
||||||
this.MethodRouter=MethodRouter{}
|
this.MethodRouter=MethodRouter{}
|
||||||
|
modeRouterStrict:=true
|
||||||
|
if this.Config.Get("modeRouterStrict").(bool)==false{
|
||||||
|
modeRouterStrict=false
|
||||||
|
}
|
||||||
if router!=nil{
|
if router!=nil{
|
||||||
for pk,pv:= range router{
|
for pk,pv:= range router{
|
||||||
|
if !modeRouterStrict{
|
||||||
|
pk=strings.ToLower(pk)
|
||||||
|
}
|
||||||
if pv!=nil{
|
if pv!=nil{
|
||||||
for ck,cv:=range pv{
|
for ck,cv:=range pv{
|
||||||
|
if !modeRouterStrict{
|
||||||
|
ck=strings.ToLower(ck)
|
||||||
|
}
|
||||||
if cv!=nil{
|
if cv!=nil{
|
||||||
for mk,mv:=range cv{
|
for mk,mv:=range cv{
|
||||||
|
if !modeRouterStrict{
|
||||||
|
mk=strings.ToLower(mk)
|
||||||
|
}
|
||||||
this.MethodRouter["/"+pk+"/"+ck+"/"+mk]=mv
|
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) {
|
func (this *Application) handler(w http.ResponseWriter, req *http.Request) {
|
||||||
|
|
||||||
o, s := this.urlSer(req.RequestURI)
|
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()
|
context.View()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user