Skip to content

Conversation

@Beormund
Copy link

@Beormund Beormund commented Nov 16, 2022

Adds ability to specify multiple parameter names

@app.resource('/cmnd/<device>/<state>')
def cmndstate(data, device, state):
    return {'device':  device, 'state':  state}

Adds ability to obtain query string as a dictionary from request object.

@app.route('/cmnd')
async def cmnd(request, response):
    d = request.read_parse_query_data()
    await response.start_html()
    await response.send(f"<html><body><h1>{d}</h1></body></html>")

Adds ability to specify multiple parameter names in restful urls.

Adds ability to obtain query string as a dictionary from request object.
Fix greedy matching of url root. Now _find_url_handler has to match path and params for parameterized urls.
@Beormund
Copy link
Author

It looks like we could get away with storing just the parameter count in params['_param_names']. I can't see the param names being used anywhere else. Perhaps change this to params['_param_count']. It could then be used to pass the correct number of arguments to the user's route function.

Changed params['_param_names'] to params['_param_count']. Also made further improvements to path/param detection in _find_url_handler.
No need for this helper method to be async.
Replaced asyncio.cancel calls with task.cancel and removed unused processed_connections count. Also, self.conns[hid] = handler is now self.conns[hid] = task.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant