jbeluch/xbmcswift2 — pull request #92 by dersphere (2013-02-09 17:10:14+00:00)
Title: added automatic url_rule generation in route()-decorator

I'm not sure if this is something you/we really want so I only updated the code. If you like it, I will add tests and update the docs.

With this change the following is possible:
```python
@plugin.route(is_root=True)
def root():
items = [
{'label': 'Latest',
'path': plugin.url_for('show_movies')},
]
return plugin.finish(items)

@plugin.route()
def show_movies():
items = [{
'label': movie['title'],
'is_playable': True,
'path': plugin.url_for(
endpoint='play_movie',
movie_id=movie['id']
)
} for movie in get_movies()]
return plugin.finish(items)

@plugin.route()
def func_with_much_params(foo, bar, lorem, ipsum):
pass

@plugin.route()
def play_movie(movie_id):
url = get_url(movie_id)
return plugin.set_resolved_url(url)
```

The URLs from the above example will be:
```
'/'
'/show_movies'
'/func_with_much_params/foo//bar//lorem//ipsum/'
'/play/movie_id/'
```

I could also be changed to _not_ add the param name, example:
```
'/'
'/show_movies'
'/func_with_much_params////'
'/play/'
```

This change should be fully backward compatible.
Personally I prefer defining the routes myself but while in development it saves some time. ;-)