0
我有一個服務器,可以接受0,1或多個以下網址參數:驗證龍捲風參數
/api/cases?id={id}&name={name}&owner={owner}&status={status}
所以這些,除其他,是正確的:
/api/cases?owner=me
/api/cases
/api/cases?name=bob&status=waiting
目前,我的代碼看起來像這樣
routes = [(r'/cases?([^/]+)', MyHandler)]
tornado.web.Application.__init__(self, routes, settings={})
class MyHandler(APIHandler):
ACCEPTED_URL_ARGS = ["id", "name", "owner", "status"]
def get(self, i):
for key in self.request.arguments:
if key not in self.ACCEPTED_URL_ARGS:
# error
有沒有更好的方法來檢查url參數?