{"id":16315162,"url":"https://github.com/robrwo/plack-middleware-emulateoptions","last_synced_at":"2025-05-05T19:52:34.614Z","repository":{"id":58448400,"uuid":"531906039","full_name":"robrwo/Plack-Middleware-EmulateOPTIONS","owner":"robrwo","description":"handle OPTIONS requests as HEAD","archived":false,"fork":false,"pushed_at":"2024-12-18T14:41:51.000Z","size":58,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-16T17:56:48.184Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robrwo.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-02T11:54:43.000Z","updated_at":"2024-12-18T14:42:30.000Z","dependencies_parsed_at":"2024-11-06T09:23:44.370Z","dependency_job_id":"d332f2bb-dd24-4b8d-b50b-7f82bdedd855","html_url":"https://github.com/robrwo/Plack-Middleware-EmulateOPTIONS","commit_stats":{"total_commits":48,"total_committers":1,"mean_commits":48.0,"dds":0.0,"last_synced_commit":"a66bfeb65391291d2f5c863a74a41a09e8997b85"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrwo%2FPlack-Middleware-EmulateOPTIONS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrwo%2FPlack-Middleware-EmulateOPTIONS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrwo%2FPlack-Middleware-EmulateOPTIONS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrwo%2FPlack-Middleware-EmulateOPTIONS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robrwo","download_url":"https://codeload.github.com/robrwo/Plack-Middleware-EmulateOPTIONS/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252566441,"owners_count":21769042,"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":[],"created_at":"2024-10-10T21:56:23.308Z","updated_at":"2025-05-05T19:52:34.588Z","avatar_url":"https://github.com/robrwo.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NAME\n\nPlack::Middleware::EmulateOPTIONS - handle OPTIONS requests as HEAD\n\n# VERSION\n\nversion v0.4.1\n\n# SYNOPSIS\n\n```perl\nuse Plack::Builder;\n\nbuilder {\n\n  enable \"EmulateOPTIONS\",\n    filter =\u003e sub {\n        my $env = shift;\n        return $env-\u003e{PATH_INFO} =~ m[^/static/];\n      };\n\n  ...\n\n};\n```\n\n# DESCRIPTION\n\nThis middleware adds support for handling HTTP `OPTIONS` requests, by internally rewriting them as `HEAD` requests.\n\nIf the requests succeed, then it will add `Allow` headers using the [\"callback\"](#callback) method.\n\nIf the requests do not succeed, then the responses are passed unchanged.\n\nYou can add the [\"filter\"](#filter) attribute to determine whether it will proxy `HEAD` requests.\n\n# ATTRIBUTES\n\n## filter\n\nThis is an optional code reference for a function that takes the [PSGI](https://metacpan.org/pod/PSGI) environment and returns true or false as to\nwhether the request should be proxied.\n\nFor instance, if you have CORS handler for a specific path, you might return false for those requests. Alternatively,\nyou might use the [\"callback\"](#callback).\n\nIf you need a different value for the `Allow` headers, then you should handle the requests separately.\n\n## callback\n\nThis is an optional code reference that modifies the response headers.\n\nBy default, it sets the `Allow` header to \"GET, HEAD, OPTIONS\".\n\nIf you override this, then you will need to manually set the header yourself, for example:\n\n```perl\nuse Plack::Util;\n\nenable \"EmulateOPTIONS\",\n  callback =\u003e sub($res, $env) {\n\n      my @allowed = qw( GET HEAD OPTIONS );\n      if ( $env-\u003e{PATH_INFO} =~ m[^/api/] ) {\n         push @allowed, qw( POST PUT DELETE );\n      }\n\n      Plack::Util::header_set( $res-\u003e[1], 'allow', join(\", \", @allowed) );\n\n    };\n```\n\nThis was added in v0.2.0.\n\n# SUPPORT FOR OLDER PERL VERSIONS\n\nSince v0.4.0, the this module requires Perl v5.20 or later.\n\nFuture releases may only support Perl versions released in the last ten (10) years.\n\n# SOURCE\n\nThe development version is on github at [https://github.com/robrwo/Plack-Middleware-EmulateOPTIONS](https://github.com/robrwo/Plack-Middleware-EmulateOPTIONS)\nand may be cloned from [git://github.com/robrwo/Plack-Middleware-EmulateOPTIONS.git](git://github.com/robrwo/Plack-Middleware-EmulateOPTIONS.git)\n\n# BUGS\n\nPlease report any bugs or feature requests on the bugtracker website\n[https://github.com/robrwo/Plack-Middleware-EmulateOPTIONS/issues](https://github.com/robrwo/Plack-Middleware-EmulateOPTIONS/issues)\n\nWhen submitting a bug or request, please include a test-file or a\npatch to an existing test-file that illustrates the bug or desired\nfeature.\n\n## Reporting Security Vulnerabilities\n\nSecurity issues should not be reported on the bugtracker website. Please see `SECURITY.md` for instructions how to\nreport security vulnerabilities\n\n# AUTHOR\n\nRobert Rothenberg \u003crrwo@cpan.org\u003e\n\n# COPYRIGHT AND LICENSE\n\nThis software is Copyright (c) 2022-2024 by Robert Rothenberg.\n\nThis is free software, licensed under:\n\n```\nThe Artistic License 2.0 (GPL Compatible)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobrwo%2Fplack-middleware-emulateoptions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobrwo%2Fplack-middleware-emulateoptions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobrwo%2Fplack-middleware-emulateoptions/lists"}