我想像这样在龙卷风中进行路径检查:
class MyRequestHandler(tornado.web.RequestHandler):
def initialize(self):
self.supported_path = ['path_a', 'path_b', 'path_c']
def get(self, action):
if action not in self.supported_path:
self.send_error(400)
def post(self, action):
if action not in self.supported_path:
self.send_error(400)
# not implemented
#def prepare(self):
# if action match the path
app = tornado.web.Application([
('^/main/(P<action>[^\/]?)/', MyRequestHandler),])
我怎样才能检查它prepare
,而不是两者get
和post
?