开发者

in appengine how can i have namespace based url routing?

开发者 https://www.devze.com 2023-01-20 11:36 出处:网络
I\'m trying to figure out how to change url routing based on namespace Say I have myapp.x.com/apage and myapp.y.com/apage, I tried the code below but

I'm trying to figure out how to change url routing based on namespace

Say I have myapp.x.com/apage and myapp.y.com/apage, I tried the code below but it doesn't work because I presume the main.py is being cached

ns = namespace_manager.google_apps_namespace()
if ns == 'x.com'
    app = WSGIApplication([
        (r'/apage', 'my.module.XHandler开发者_如何学Go'),
    ])
else:
    app = WSGIApplication([
        (r'/apage', 'my.module.YHandler'),
    ])

Is there any other way to do it besides of course turning each handler into a url router?


You need to write your own middleware that routes to different apps based on domain. See DomainMiddleware in this blog post for an example.

0

精彩评论

暂无评论...
验证码 换一张
取 消