{"id":19518956,"url":"https://github.com/inhabitedtype/ocaml-dispatch","last_synced_at":"2025-06-15T09:05:49.294Z","repository":{"id":42499902,"uuid":"44256882","full_name":"inhabitedtype/ocaml-dispatch","owner":"inhabitedtype","description":"Path-based dispatching for client- and server-side applications.","archived":false,"fork":false,"pushed_at":"2022-09-26T08:56:20.000Z","size":107,"stargazers_count":45,"open_issues_count":1,"forks_count":9,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-26T07:35:18.515Z","etag":null,"topics":["web"],"latest_commit_sha":null,"homepage":null,"language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inhabitedtype.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":"2015-10-14T15:23:24.000Z","updated_at":"2024-11-17T16:36:30.000Z","dependencies_parsed_at":"2023-01-18T13:52:22.855Z","dependency_job_id":null,"html_url":"https://github.com/inhabitedtype/ocaml-dispatch","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/inhabitedtype/ocaml-dispatch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inhabitedtype%2Focaml-dispatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inhabitedtype%2Focaml-dispatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inhabitedtype%2Focaml-dispatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inhabitedtype%2Focaml-dispatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inhabitedtype","download_url":"https://codeload.github.com/inhabitedtype/ocaml-dispatch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inhabitedtype%2Focaml-dispatch/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259949660,"owners_count":22936407,"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":["web"],"created_at":"2024-11-11T00:15:31.532Z","updated_at":"2025-06-15T09:05:49.259Z","avatar_url":"https://github.com/inhabitedtype.png","language":"OCaml","funding_links":[],"categories":["Web Development"],"sub_categories":[],"readme":"# ocaml-dispatch\n\nocaml-dispatch provides a basic mechanism for dispatching a request to a\nhandler based on hierarchical path names conventionally found in URIs. It can be\nused both for dispatching requests in a server, as well as handing changes to\nhierarchical fragments in a client-side application.\n\n[![Build Status](https://travis-ci.org/inhabitedtype/ocaml-dispatch.svg?branch=master)](https://travis-ci.org/inhabitedtype/ocaml-dispatch)\n\n## Installation\n\nInstall the library and its depenencies via [OPAM][opam]:\n\n[opam]: http://opam.ocaml.org/\n\n```bash\nopam install dispatch\n```\n\n## Development\n\nTo install development versions of the library, pin the package from the root\nof the repository:\n\n```bash\nopam pin add .\n```\n\nYou can install the latest changes by commiting them to the local git\nrepository and running:\n\n```bash\nopam upgrade dispatch\n```\n\nFor building and running the tests during development, you will need to install\nthe `alcotest` package and reconfigure the build process to enable tests:\n\n```bash\nopam install alcotest\ndune runtest\n```\n\n## Usage\n\nDispatch is designed to work with whatever sort of handler you care to use,\nwhether it's synchronous, Lwt-based, or Async-based. Here's a simple example of\nusing the `Dispatch.DSL` module to setup routing for a \"Hello, World!\" server.\nThe example assumes a `Server` module and `request` type, and that handlers\nshould return strings that will be interpreted as the body of the response.\n\n```ocaml\nopen Dispatch\n\nlet hello_handler keys rest request =\n  let who = try List.assoc \"who\" keys with Not_found -\u003e \"World\" in\n  Printf.sprintf \"Hello, %s!\" who\n;;\n\nlet handler request =\n  let routes = \n    DSL.create \n      [ \"/\"           , hello_handler\n      ; \"/hello/:who/\", hello_handler\n      ] \n  in\n  match dispatch routes request.path with\n  | Some handler -\u003e handler request\n  | None         -\u003e \"Not found!\"\n;;\n\nlet _ =\n  Server.start handler\n```\n\n## License\n\nBSD3, see LICENSE file for its text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finhabitedtype%2Focaml-dispatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finhabitedtype%2Focaml-dispatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finhabitedtype%2Focaml-dispatch/lists"}