{"id":15010677,"url":"https://github.com/unbounce/encors","last_synced_at":"2025-04-09T18:34:34.044Z","repository":{"id":23601477,"uuid":"26970330","full_name":"unbounce/encors","owner":"unbounce","description":"encors is a CORS library for ring.","archived":false,"fork":false,"pushed_at":"2020-05-14T16:34:02.000Z","size":72,"stargazers_count":22,"open_issues_count":1,"forks_count":2,"subscribers_count":56,"default_branch":"master","last_synced_at":"2025-03-19T23:19:14.940Z","etag":null,"topics":["clojure","cors","owner-platform-services","release-not-compliant","ring","workflow-trunk"],"latest_commit_sha":null,"homepage":"https://cljdoc.org/d/com.unbounce/encors/","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/unbounce.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-21T17:31:04.000Z","updated_at":"2025-03-12T19:56:21.000Z","dependencies_parsed_at":"2022-08-22T02:10:20.417Z","dependency_job_id":null,"html_url":"https://github.com/unbounce/encors","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unbounce%2Fencors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unbounce%2Fencors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unbounce%2Fencors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unbounce%2Fencors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unbounce","download_url":"https://codeload.github.com/unbounce/encors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248088268,"owners_count":21045672,"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":["clojure","cors","owner-platform-services","release-not-compliant","ring","workflow-trunk"],"created_at":"2024-09-24T19:35:19.854Z","updated_at":"2025-04-09T18:34:34.013Z","avatar_url":"https://github.com/unbounce.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cpre\u003e\n _____ _      ____ ____  ____  ____\n/  __// \\  /|/   _Y  _ \\/  __\\/ ___\\\n|  \\  | |\\ |||  / | / \\||  \\/||    \\\n|  /_ | | \\|||  \\_| \\_/||    /\\___ |\n\\____\\\\_/  \\|\\____|____/\\_/\\_\\\\____/\n\u003c/pre\u003e\n\nYet again another [CORS](http://www.w3.org/TR/cors/) library for ring.\n\n[![Build Status](https://travis-ci.org/unbounce/encors.svg?branch=master)](https://travis-ci.org/unbounce/encors)\n\u003cbr/\u003e\n[![Clojars Project](http://clojars.org/com.unbounce/encors/latest-version.svg)](http://clojars.org/com.unbounce/encors)\n\n## Usage\n\nAdd CORS support to ring apps, supporting both synchronous and asynchronous\n([aleph](https://github.com/ztellman/aleph)) handlers.\n\n### `wrap-cors`\n\nReceives 2 arguments:\n\n  1) The ring app being wrapped.\n\n\n  2) A map that _must_ have the following keys:\n\n  - `:allowed-origins`\n\n    A set that specifies which origins are allowed by the\n    middleware. A value of `:star-origin` indicates unrestricted cross-origin\n    sharing and results in `*` as value for the\n    `Access-Control-Allow-Origin` HTTP response header.\n    A value of `:match-origin` will always return the incoming origin header.\n\n  - `:allowed-methods`\n\n    A set that specifies the HTTP methods allowed in CORS requests.\n    (valid values are [here](https://github.com/unbounce/encors/blob/master/src/com/unbounce/encors/types.clj#L17))\n\n  - `:request-headers`\n\n    A set of field names of HTTP request headers that are allowed in\n    CORS requests.  Some headers found on a simple CORS implementation\n    are included implicitly (except `Content-Type`)\n\n  - `:exposed-headers`\n\n    A set of HTTP header field names that will be exposed on the\n    client (can be nil).\n\n  - `:max-age`\n\n    Number of seconds that the response may be cached by the client\n    (can be nil).\n\n  - `:allow-credentials?`\n\n    A boolean that if `true`, adds the\n    `Access-Control-Allow-Credentials` header on preflight requests.\n\n  - `:origin-varies?`\n\n    If the resource is shared by multiple origins but\n    `Access-Control-Allow-Origin` is not set to `*` this may be set to\n    `true`.\n\n  - `:require-origin?`\n\n    If this is `true` and the request does not include an `Origin`\n    header the response will have HTTP status 400 (bad request) and\n    the body will contain a short error message.\n\n  - `:ignore-failures?`\n\n    In case that:\n\n      *  the request contains an `Origin` header and\n\n      *  the client does not conform with the CORS protocol\n         (__request is out of scope__)\n\n    then\n\n      * the request is passed on unchanged to the application if this\n        field is `true` or\n\n      * a response with HTTP status 400 (bad request) and short error\n        message will be returned if this field is `false`\n\n\nExample:\n\n```clojure\n(ns my.ring-app\n  (:require\n    [com.unbounce.encors :refer [wrap-cors]]\n    ;; ... other misc ring imports\n    )\n\n(defn raw-app [req]\n  ;; return response here\n  )\n\n(def cors-policy\n     { :allowed-origins #{\"example.com\"}\n       :allowed-methods #{:get}\n       :request-headers #{\"X-Example-Header\"}\n       :exposed-headers nil\n       :allow-credentials? true\n       :origin-varies? false\n       :max-age nil\n       :require-origin? true\n       :ignore-failures? false\n     })\n\n(def app (wrap-cors raw-app cors-policy))\n```\n\n### `com.unbounce.encors.aleph/wrap-cors`\n\nSame as `wrap-cors`, but supports aleph's deferred responses.\n\nNOTE: This is only avaiable if you have\n[ztellman/aleph](https://github.com/ztellman/aleph) on the classpath.\n\n## License\n\nCopyright © 2014-2020 Unbounce Marketing Solutions Inc.\n\nDistributed under the [MIT License (MIT)](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funbounce%2Fencors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funbounce%2Fencors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funbounce%2Fencors/lists"}