{"id":15432884,"url":"https://github.com/simonw/datasette-configure-asgi","last_synced_at":"2026-04-30T00:32:22.608Z","repository":{"id":62566803,"uuid":"228485806","full_name":"simonw/datasette-configure-asgi","owner":"simonw","description":"Datasette plugin for configuring arbitrary ASGI middleware","archived":false,"fork":false,"pushed_at":"2019-12-16T22:19:49.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-18T07:53:11.368Z","etag":null,"topics":["asgi","datasette","datasette-io","datasette-plugin"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simonw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-16T22:17:10.000Z","updated_at":"2020-08-25T15:54:32.000Z","dependencies_parsed_at":"2022-11-03T16:15:14.603Z","dependency_job_id":null,"html_url":"https://github.com/simonw/datasette-configure-asgi","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonw%2Fdatasette-configure-asgi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonw%2Fdatasette-configure-asgi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonw%2Fdatasette-configure-asgi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonw%2Fdatasette-configure-asgi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonw","download_url":"https://codeload.github.com/simonw/datasette-configure-asgi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245978277,"owners_count":20703678,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asgi","datasette","datasette-io","datasette-plugin"],"created_at":"2024-10-01T18:29:00.140Z","updated_at":"2026-04-30T00:32:17.589Z","avatar_url":"https://github.com/simonw.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# datasette-configure-asgi\n\n[![PyPI](https://img.shields.io/pypi/v/datasette-configure-asgi.svg)](https://pypi.org/project/datasette-configure-asgi/)\n[![CircleCI](https://circleci.com/gh/simonw/datasette-configure-asgi.svg?style=svg)](https://circleci.com/gh/simonw/datasette-configure-asgi)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/datasette-configure-asgi/blob/master/LICENSE)\n\nDatasette plugin for configuring arbitrary ASGI middleware\n\n## Installation\n\n    pip install datasette-configure-asgi\n\n## Usage\n\nThis plugin only takes effect if your `metadata.json` file contains relevant top-level plugin configuration in a `\"datasette-configure-asgi\"` configuration key.\n\nFor example, to wrap your Datasette instance in the `asgi-log-to-sqlite` middleware configured to write logs to `/tmp/log.db` you would use the following:\n\n```json\n{\n    \"plugins\": {\n        \"datasette-configure-asgi\": [\n            {\n                \"class\": \"asgi_log_to_sqlite.AsgiLogToSqlite\",\n                \"args\": {\n                    \"file\": \"/tmp/log.db\"\n                }\n            }\n        ]\n    }\n}\n```\n\nThe `\"datasette-configure-asgi\"` key should be a list of JSON objects. Each object should have a `\"class\"` key indicating the class to be used, and an optional `\"args\"` key providing any necessary arguments to be passed to that class constructor.\n\n## Plugin structure\n\nThis plugin can be used to wrap your Datasette instance in any ASGI middleware that conforms to the following structure:\n\n```python\nclass SomeAsgiMiddleware:\n    def __init__(self, app, arg1, arg2):\n        self.app = app\n        self.arg1 = arg1\n        self.arg2 = arg2\n\n    async def __call__(self, scope, receive, send):\n        start = time.time()\n        await self.app(scope, receive, send)\n        end = time.time()\n        print(\"Time taken: {}\".format(end - start))\n```\n\nSo the middleware is a class with a constructor which takes the wrapped application as a first argument, `app`, followed by further named arguments to configure the middleware. It provides an `async def __call__(self, scope, receive, send)` method to implement the middleware's behavior.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonw%2Fdatasette-configure-asgi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonw%2Fdatasette-configure-asgi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonw%2Fdatasette-configure-asgi/lists"}