@@ -151,27 +151,69 @@ end
151151return UserService
152152]]
153153
154+ local admin_plugin_tpl = [[
155+ local AdminPlugin = require('vanilla.v.plugin'):new()
156+
157+ function AdminPlugin:routerStartup(request, response)
158+ pp('<pre>')
159+ if request.method == 'GET' then
160+ pp('-----------' .. pps(request.headers) .. '----------')
161+ else
162+ pp(request.headers)
163+ end
164+ end
165+
166+ function AdminPlugin:routerShutdown(request, response)
167+ end
168+
169+ function AdminPlugin:dispatchLoopStartup(request, response)
170+ end
171+
172+ function AdminPlugin:preDispatch(request, response)
173+ end
174+
175+ function AdminPlugin:postDispatch(request, response)
176+ end
177+
178+ function AdminPlugin:dispatchLoopShutdown(request, response)
179+ end
180+
181+ return AdminPlugin
182+ ]]
183+
154184
155185local bootstrap = [[
156186local Bootstrap = require('vanilla.v.bootstrap'):new(dispatcher)
157187
188+ function Bootstrap:initWaf()
189+ require 'vanilla.sys.waf.acc'
190+ end
191+
158192function Bootstrap:initErrorHandle()
159193 self.dispatcher:setErrorHandler({controller = 'error', action = 'error'})
160194end
161195
162196function Bootstrap:initRoute()
163- local router = require('vanilla.v.routes.simple'):new(self.dispatcher:getRequest())
164- self.dispatcher.router = router
197+ local router = self.dispatcher:getRouter()
198+ local simple_route = require('vanilla.v.routes.simple'):new(self.dispatcher:getRequest())
199+ router:addRoute(simple_route, true)
165200end
166201
167202function Bootstrap:initView()
168203end
169204
205+ function Bootstrap:initPlugin()
206+ local admin_plugin = require('plugins.admin'):new()
207+ self.dispatcher:registerPlugin(admin_plugin);
208+ end
209+
170210function Bootstrap:boot_list()
171211 return {
212+ Bootstrap.initWaf,
172213 Bootstrap.initErrorHandle,
173214 Bootstrap.initRoute,
174- Bootstrap.initView
215+ Bootstrap.initView,
216+ Bootstrap.initPlugin,
175217 }
176218end
177219
@@ -487,7 +529,7 @@ VaApplication.files = {
487529 [' application/library/.gitkeep' ] = " " ,
488530 [' application/models/dao/table.lua' ] = dao ,
489531 [' application/models/service/user.lua' ] = service ,
490- [' application/plugins/.gitkeep ' ] = " " ,
532+ [' application/plugins/admin.lua ' ] = admin_plugin_tpl ,
491533 [' application/views/index/index.html' ] = index_tpl ,
492534 [' application/views/error/error.html' ] = error_tpl ,
493535 [' application/bootstrap.lua' ] = bootstrap ,
0 commit comments