{"id":28614191,"url":"https://github.com/perldancer/dancer2-plugin-deferred","last_synced_at":"2025-08-10T00:15:14.344Z","repository":{"id":7296208,"uuid":"8612265","full_name":"PerlDancer/dancer2-plugin-deferred","owner":"PerlDancer","description":"Defer messages or data across redirections","archived":false,"fork":false,"pushed_at":"2020-10-01T14:06:11.000Z","size":66,"stargazers_count":4,"open_issues_count":2,"forks_count":6,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-06-12T01:13:29.666Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://metacpan.org/release/Dancer2-Plugin-Deferred","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/PerlDancer.png","metadata":{"files":{"readme":"README.pod","changelog":"Changes","contributing":"CONTRIBUTING","funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-03-06T20:18:57.000Z","updated_at":"2020-08-21T17:25:13.000Z","dependencies_parsed_at":"2022-09-22T12:36:29.832Z","dependency_job_id":null,"html_url":"https://github.com/PerlDancer/dancer2-plugin-deferred","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/PerlDancer/dancer2-plugin-deferred","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerlDancer%2Fdancer2-plugin-deferred","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerlDancer%2Fdancer2-plugin-deferred/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerlDancer%2Fdancer2-plugin-deferred/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerlDancer%2Fdancer2-plugin-deferred/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PerlDancer","download_url":"https://codeload.github.com/PerlDancer/dancer2-plugin-deferred/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerlDancer%2Fdancer2-plugin-deferred/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269656018,"owners_count":24454571,"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-08-09T02:00:10.424Z","response_time":111,"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":"2025-06-12T01:13:23.256Z","updated_at":"2025-08-10T00:15:14.296Z","avatar_url":"https://github.com/PerlDancer.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"=head1 SYNOPSIS\n\n  use Dancer2::Plugin::Deferred;\n\n  get '/defer' =\u003e sub {\n    deferred error =\u003e \"Klaatu barada nikto\";\n    redirect '/later';\n  }\n\n  get '/later' =\u003e sub {\n    template 'later';\n  }\n\n  # in template 'later.tt'\n  \u003c% IF deferred.error %\u003e\n  \u003cdiv class=\"error\"\u003e\u003c% deferred.error %\u003e\u003c/div\u003e\n  \u003c% END %\u003e\n\n=head1 DESCRIPTION\n\nThis L\u003cDancer2\u003e plugin provides a method for deferring a one-time message across\na redirect.  It is similar to \"flash\" messages, but without the race conditions\nthat can result from multiple tabs in a browser or from AJAX requests.  It is\nsimilar in design to L\u003cCatalyst::Plugin::StatusMessage\u003e, but adapted for Dancer2.\n\nIt works by creating a unique message ID within the session that holds deferred\ndata.  The message ID is automatically added as a query parameter to redirection\nrequests.  It's sort of like a session within a session, but tied to a request\nrather than global to the browser.  (It will even chain across multiple\nredirects.)\n\nWhen a template is rendered, a pre-template hook retrieves the data and\ndeletes it from the session.  Alternatively, the data can be retrieved manually\n(which will also automatically delete the data.)\n\nAlternatively, the message ID parameters can be retrieved and used to\nconstruct a hyperlink for a message to be retrieved later.  In this case,\nthe message is preserved past the template hook.  (The template should be\nsure not to render the message if not desired.)\n\n=head1 USAGE\n\n=head2 deferred\n\n  deferred $key =\u003e $value;\n  $value = deferred $key; # also deletes $key\n\nThis function works just like C\u003cvar\u003e or C\u003csession\u003e, except that it lasts only\nfor the current request and across any redirects.  Data is deleted if accessed.\nIf a key is set to an undefined value, the key is deleted from the deferred\ndata hash.\n  \n=head2 all_deferred\n\n  template 'index', { deferred =\u003e all_deferred };\n\nThis function returns all the deferred data as a hash reference and deletes\nthe stored data.  This is called automatically in the C\u003cbefore_template_render\u003e\nhook, but is available if someone wants to have manual control.\n\n=head2 deferred_param\n\n  template 'index' =\u003e { link =\u003e uri_for( '/other', { deferred_param } ) };\n\nThis function returns the parameter key and value used to propagate the\nmessage to another request.  Using this function toggles the C\u003cvar_keep_key\u003e\nvariable to true to ensure the message remains to be retrieved by the link.\n\n=head1 CONFIGURATION\n\n=head1 SEE ALSO\n\n=head1 ACKNOWLEDGMENTS\n\nThank you to mst for explaining why L\u003cCatalyst::Plugin::StatusMessages\u003e does\nwhat it does and putting up with my dumb ideas along the way.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperldancer%2Fdancer2-plugin-deferred","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperldancer%2Fdancer2-plugin-deferred","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperldancer%2Fdancer2-plugin-deferred/lists"}