channelstream: try to use proxy url's unless ws urls are not explictly defined

This commit is contained in:
Marcin Lulek 2016-09-19 13:48:37 +02:00
parent 1e756c22ff
commit 13cae52005
3 changed files with 17 additions and 6 deletions

View file

@ -420,7 +420,9 @@ channelstream.server = 127.0.0.1:9800
## location of the channelstream server from outside world
## most likely this would be an http server special backend URL, that handles
## websocket connections see nginx example for config
channelstream.ws_url = ws://rhodecode.yourserver.com/_channelstream
# channelstream.ws_url = ws://rhodecode.yourserver.com/_channelstream
## proxy path that can be used by http daemons for exposing channelstream
# channelstream.proxy_path = /_channelstream
channelstream.secret = secret
channelstream.history.location = %(here)s/channelstream_history

View file

@ -394,7 +394,9 @@ channelstream.server = 127.0.0.1:9800
## location of the channelstream server from outside world
## most likely this would be an http server special backend URL, that handles
## websocket connections see nginx example for config
channelstream.ws_url = ws://rhodecode.yourserver.com/_channelstream
# channelstream.ws_url = ws://rhodecode.yourserver.com/_channelstream
## proxy path that can be used by http daemons for exposing channelstream
# channelstream.proxy_path = /_channelstream
channelstream.secret = secret
channelstream.history.location = %(here)s/channelstream_history

View file

@ -27,11 +27,15 @@ from rhodecode.lib.ext_json import json
def url_gen(request):
registry = request.registry
longpoll_url = registry.settings.get('channelstream.longpoll_url', '')
ws_url = registry.settings.get('channelstream.ws_url', '')
proxy_url = request.route_url('channelstream_proxy')
urls = {
'connect': request.route_url('channelstream_connect'),
'subscribe': request.route_url('channelstream_subscribe'),
'longpoll': request.registry.settings.get('channelstream.longpoll_url', ''),
'ws': request.registry.settings.get('channelstream.ws_url', '')
'connect': request.route_path('channelstream_connect'),
'subscribe': request.route_path('channelstream_subscribe'),
'longpoll': longpoll_url or proxy_url,
'ws': ws_url or proxy_url.replace('http', 'ws')
}
return json.dumps(urls)
@ -78,4 +82,7 @@ def includeme(config):
config.add_route(
name='channelstream_subscribe',
pattern=ADMIN_PREFIX + '/channelstream/subscribe')
config.add_route(
name='channelstream_proxy',
pattern=settings.get('channelstream.proxy_path') or '/_channelstream')
config.scan('rhodecode.channelstream')