{"id":22196709,"url":"https://github.com/druids/duct.module.bidi","last_synced_at":"2025-09-06T17:37:10.113Z","repository":{"id":69906889,"uuid":"131991984","full_name":"druids/duct.module.bidi","owner":"druids","description":"Duct module and router for the Bidi routing library","archived":false,"fork":false,"pushed_at":"2018-06-08T06:47:20.000Z","size":27,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T22:41:31.396Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Clojure","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/druids.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-03T12:30:30.000Z","updated_at":"2019-03-05T16:51:53.000Z","dependencies_parsed_at":"2023-03-05T18:00:52.724Z","dependency_job_id":null,"html_url":"https://github.com/druids/duct.module.bidi","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/druids/duct.module.bidi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/druids%2Fduct.module.bidi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/druids%2Fduct.module.bidi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/druids%2Fduct.module.bidi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/druids%2Fduct.module.bidi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/druids","download_url":"https://codeload.github.com/druids/duct.module.bidi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/druids%2Fduct.module.bidi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273937123,"owners_count":25194326,"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","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"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":[],"created_at":"2024-12-02T14:16:12.995Z","updated_at":"2025-09-06T17:37:10.097Z","avatar_url":"https://github.com/druids.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"Duct module.bidi\n================\n\nA [Duct](https://github.com/duct-framework/duct) module that sets [Bidi]() as the router for your application.\n\n[![CircleCI](https://circleci.com/gh/druids/duct.module.bidi.svg?style=svg)](https://circleci.com/gh/druids/duct.module.bidi)\n[![Dependencies Status](https://jarkeeper.com/druids/duct.module.bidi/status.png)](https://jarkeeper.com/druids/duct.module.bidi)\n[![License](https://img.shields.io/badge/MIT-Clause-blue.svg)](https://opensource.org/licenses/MIT)\n\n\nLeiningen/Boot\n--------------\n\nTo install, add the following to you project `:dependencies`:\n\n```clojure\n[duct.module.bidi \"0.5.0\"]\n```\n\n\nUsage\n-----\n\nTo add this module to your configuration, add the `:duct.module/bidi` key. For example:\n\n```clojure\n{:duct.core/project-ns foo\n :duct.module/bidi [{\"/index\" :index}]\n :foo.handler/index {}}\n```\n\nAnd `foo/handler/index.clj` may looks like:\n\n```clojure\n(ns foo.handler.index\n  (:require\n    [integrant.core :as ig]))\n\n(defmethod ig/init-key :foo.handler/index\n  [_ options]\n  (fn [request] ;; :bidi-route will be :index\n    {:status 200, :body \"Index page\", :headers {\"Content-Type\" \"text/html\"}})))\n```\n\nA route name is in a request under `:bidi-route` key.\n\nRoutes can grouped into one handler:\n\n```clojure\n{:duct.core/project-ns foo\n :duct.module/bidi [{\"/\" :index\n                     \"/api/users\" {\"\" :api/users-list\n                                   [\"/\" :id] :api/users-detail}}]\n :foo.handler/index {}\n :foo.handler/api {}}\n```\n\nAnd `foo/handler/api.clj` may looks like:\n\n```clojure\n(ns foo.handler.api\n  (:require\n    [integrant.core :as ig]))\n\n(defmethod ig/init-key :foo.handler/api\n  [_ options]\n  (fn [request]\n    (case (:bidi-route request)\n      :api/users-list {:status 200, :body []})\n      :api/users-detail {:status 200, :body {:id 1, ...\n```\n\nRoutes can be composed from multiple components:\n\n```clojure\n{:duct.core/project-ns foo\n :foo/private-routes {\"/private\" {\"/foo\" :foo, \"/bar\" :bar}}\n :foo/public-routes {\"/public\" {\"/biz\" :biz, \"/baz\" :baz}}\n :duct.module/bidi [#ig/ref :foo/private-routes\n                    #ig/ref :foo/public-routes]}\n```\nThis is useful e.g. for development only routes.\n\nWhen a server started you can find a route composition under `:duct.router/routes` key.\n\nE.g.\n\n```clojure\n(:duct.router/routes config)\n[\"\"\n {\"/private\" {\"/foo\" :foo, \"/bar\" :bar}}\n  \"/public\" {\"/biz\" :biz, \"/baz\" :baz}}]\n```\n\nThus you can reverse routes (e.g. when sending an e-mail message) by calling\n\n```clojure\n(require '[bidi.bidi :as bidi])\n\n(bidi/route-for (:duct.router/routes config) :bar)\n;; \"/private/bar\"\n```\n\n\nTesting\n-------\n\nFor testing there is a function `route` that associates a matched route into a request, if a uri matches to any given\n routes. Example:\n\n```clojure\n(require '[duct.routes.bidi-testing :as bidi])\n(require '[integrant.core :as ig])\n(require '[ring.mock.request :as mock])\n\n(let [routes [\"\" {\"/hello\" {:get :api/hello}}]\n      handler (ig/init-key :myapp.handler/api {})\n      response (handler (-\u003e :get (mock/request \"/hello\") (bidi/route routes)))]]\n                                                          ^--- it sets `:api/hello` under `:bidi-route` key\n  ...)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdruids%2Fduct.module.bidi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdruids%2Fduct.module.bidi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdruids%2Fduct.module.bidi/lists"}