{"id":34133885,"url":"https://github.com/flick-web/dispatch","last_synced_at":"2026-04-06T02:02:04.881Z","repository":{"id":57520541,"uuid":"250815334","full_name":"flick-web/dispatch","owner":"flick-web","description":"Just your average Go API framework","archived":false,"fork":false,"pushed_at":"2021-11-11T22:53:55.000Z","size":43,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-07-27T22:06:51.658Z","etag":null,"topics":["api","framework","go","golang","json","json-api","rest","rest-api"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flick-web.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":"2020-03-28T14:28:13.000Z","updated_at":"2021-11-11T22:53:47.000Z","dependencies_parsed_at":"2022-09-26T18:01:01.322Z","dependency_job_id":null,"html_url":"https://github.com/flick-web/dispatch","commit_stats":null,"previous_names":[],"tags_count":6,"template":null,"template_full_name":null,"purl":"pkg:github/flick-web/dispatch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flick-web%2Fdispatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flick-web%2Fdispatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flick-web%2Fdispatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flick-web%2Fdispatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flick-web","download_url":"https://codeload.github.com/flick-web/dispatch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flick-web%2Fdispatch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31456664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T21:22:52.476Z","status":"online","status_checked_at":"2026-04-06T02:00:07.287Z","response_time":112,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["api","framework","go","golang","json","json-api","rest","rest-api"],"created_at":"2025-12-15T01:14:43.882Z","updated_at":"2026-04-06T02:02:04.876Z","avatar_url":"https://github.com/flick-web.png","language":"Go","readme":"# github.com/flick-web/dispatch\n\n[![](https://img.shields.io/badge/godoc-reference-5272B4.svg)](https://godoc.org/github.com/flick-web/dispatch)\n\nDispatch is a not-too-complicated framework meant for creating super quick and easy JSON APIs. Error handling, CORS, JSON parsing, and more are all handled out of the box.\n\n## Basic Usage\n\nThis program creates and serves an API with a single endpoint. The endpoint simply returns a string composed with the `{name}` path variable.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"net/http\"\n\n\t\"github.com/flick-web/dispatch\"\n)\n\nfunc rootHandler(ctx *dispatch.Context) string {\n\treturn fmt.Sprintf(\"Hello, %s!\", ctx.PathVars[\"name\"])\n}\n\nfunc main() {\n\tapi := \u0026dispatch.API{}\n\tapi.AddEndpoint(\"GET/{name}\", rootHandler)\n\thttp.HandleFunc(\"/\", api.HTTPProxy)\n\tlog.Fatal(http.ListenAndServe(\":8000\", nil))\n}\n```\n\nFor a real-world example, check out [pjournal](https://github.com/olafal0/pjournal), a fully-fledged personal journaling web app.\n\n## API Paths\n\nPaths are expressed as a simple string, in the form:\n\n`METHOD/path/{pathvar}`\n\nAny path variables in curly braces will be automatically parsed and provided to handler functions in the `dispatch.Context.PathVars` map. Any path elements not in curly braces are treated as literals, and must be matched for the handler to be called.\n\n## API Endpoints\n\nEndpoints return JSON when used, but the handler functions themselves can accept and return any time, with certain restrictions.\n\nA handler function's **input** signature can be any of these four types:\n\n- `(none)`\n- `(*dispatch.Context)`\n- `(\u003cAnyType\u003e)`\n- `(\u003cAnyType\u003e, *dispatch.Context)` (order does not matter)\n\nIf the handler accepts an input type other than `*dispatch.Context`, it can be anything—a string, a struct, or whatever else. Dispatch will automagically marshal any incoming JSON into your type for you.\n\nA handler function's **output** signature is slightly more restricted:\n\n- `(none)`\n- `(error)`\n- `(\u003cAnyType\u003e)`\n- `(\u003cAnyType\u003e, error)` (order **does** matter)\n\nIf your function returns a `*dispatch.APIError`, its status code and error message will be used for the response. If your function returns a plain error, the handler provided by the `api` package will automatically return an HTTP error. `dispatch.ErrorNotFound` and `dispatch.ErrorBadRequest` errors will also be accompanied by correct HTTP status codes. Otherwise, dispatch will simply return status 500 and the text of your error.\n\n## Middleware\n\nThe `api.AddEndpoint` method also allows adding middleware hooks. These hooks are functions which will be called before the endpoint handler is called, and can choose to modify the method, path, context, or input of the endpoint before it is passed along. If the hook returns an error, execution of the endpoint will halt. This is useful for things like authentication checks, which must happen before the function is triggered, and must be able to return early if a call isn't authorized.\n\n## Known Issues/Disclaimer\n\nAccess control headers allow a hardcoded value of `*` for the origin, and only specific content types.\n\nDispatch was created for a specific purpose, so there are many parts of the library that are too inflexible for many use cases.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflick-web%2Fdispatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflick-web%2Fdispatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflick-web%2Fdispatch/lists"}