From 32a131cb49405a82662cf3d063ba67ff4734e913 Mon Sep 17 00:00:00 2001 From: leetaifook Date: Fri, 11 Jan 2013 16:22:26 +0800 Subject: [PATCH] Change code structure --- web/page.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/web/page.go b/web/page.go index a8778ac..fd6743a 100644 --- a/web/page.go +++ b/web/page.go @@ -104,6 +104,9 @@ func (p *Page) Init(w http.ResponseWriter, r *http.Request) { p.GET = p.site.base.getHttpGet(r) p.POST = p.site.base.getHttpPost(r, p.MAX_FORM_SIZE) p.COOKIE = p.site.base.getHttpCookie(r) +} + +func (p *Page) initModule(w http.ResponseWriter, r *http.Request) { if p.site.supportSession { switch p.Config.SessionType { case "file": @@ -129,6 +132,8 @@ func (p *Page) Init(w http.ResponseWriter, r *http.Request) { if p.site.supportI18n { p.LANG = func() map[string]string { + log.Debug(" ", `p.TARGET_LANG: `, p.TARGET_LANG) + if p.TARGET_LANG == "" { p.TARGET_LANG = strings.TrimSpace(r.Header.Get("Accept-Language")) if i := strings.Index(p.TARGET_LANG, ","); i != -1 { @@ -535,6 +540,8 @@ func (p *Page) routeController(i interface{}, w http.ResponseWriter, r *http.Req ppc.callMethod(tpc, vpc, "Init", rvr, rvw) } + ppc.initModule(w, r) + if _, ok := tpc.MethodByName(ppc.CurrentAction); ok && ppc.filterMethod(ppc.CurrentAction) { ppc.filterDoMethod(tpc, vpc, "Before_", rvr, rvw) ppc.callMethod(tpc, vpc, "Before_"+ppc.CurrentAction, rvr, rvw)