{"id": 645975649, "node_id": "MDU6SXNzdWU2NDU5NzU2NDk=", "number": 867, "title": "register_routes() should support non-async view functions too", "user": {"value": 9599, "label": "simonw"}, "state": "closed", "locked": 0, "assignee": null, "milestone": {"value": 5533512, "label": "Datasette 0.45"}, "comments": 1, "created_at": "2020-06-26T03:11:25Z", "updated_at": "2020-06-27T18:30:41Z", "closed_at": "2020-06-27T18:30:40Z", "author_association": "OWNER", "pull_request": null, "body": "I was looking at this: https://github.com/simonw/datasette-block-robots/blob/main/datasette_block_robots/__init__.py\r\n```python\r\nfrom datasette import hookimpl\r\nfrom datasette.utils.asgi import Response\r\n\r\n\r\nasync def robots_txt():\r\n return Response.text(\"User-agent: *\\nDisallow: /\")\r\n\r\n\r\n@hookimpl\r\ndef register_routes():\r\n return [\r\n (r\"^/robots\\.txt$\", robots_txt),\r\n ]\r\n```\r\nAnd I realized that if `register_routes()` could support non-async view functions it could be reduced to this:\r\n```python\r\n@hookimpl\r\ndef register_routes():\r\n return [\r\n (r\"^/robots\\.txt$\", lambda: Response.text(\"User-agent: *\\nDisallow: /\")),\r\n ]\r\n```", "repo": {"value": 107914493, "label": "datasette"}, "type": "issue", "active_lock_reason": null, "performed_via_github_app": null, "reactions": "{\"url\": \"https://api.github.com/repos/simonw/datasette/issues/867/reactions\", \"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "draft": null, "state_reason": "completed"}