{"id":16307593,"url":"https://github.com/kfly8/p5-amon2-plugin-web-cpaneljson","last_synced_at":"2025-10-13T05:17:46.424Z","repository":{"id":62431236,"uuid":"489333785","full_name":"kfly8/p5-Amon2-Plugin-Web-CpanelJSON","owner":"kfly8","description":"Amon2 plugin for Cpanel::JSON","archived":false,"fork":false,"pushed_at":"2022-06-03T13:25:47.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T19:57:30.878Z","etag":null,"topics":["perl"],"latest_commit_sha":null,"homepage":"","language":"Perl","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/kfly8.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","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":"2022-05-06T11:47:34.000Z","updated_at":"2023-04-14T23:47:12.000Z","dependencies_parsed_at":"2022-11-01T20:46:27.143Z","dependency_job_id":null,"html_url":"https://github.com/kfly8/p5-Amon2-Plugin-Web-CpanelJSON","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfly8%2Fp5-Amon2-Plugin-Web-CpanelJSON","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfly8%2Fp5-Amon2-Plugin-Web-CpanelJSON/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfly8%2Fp5-Amon2-Plugin-Web-CpanelJSON/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfly8%2Fp5-Amon2-Plugin-Web-CpanelJSON/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kfly8","download_url":"https://codeload.github.com/kfly8/p5-Amon2-Plugin-Web-CpanelJSON/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248625510,"owners_count":21135513,"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":["perl"],"created_at":"2024-10-10T21:14:40.005Z","updated_at":"2025-10-13T05:17:41.393Z","avatar_url":"https://github.com/kfly8.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Actions Status](https://github.com/kfly8/p5-Amon2-Plugin-Web-CpanelJSON/actions/workflows/test.yml/badge.svg)](https://github.com/kfly8/p5-Amon2-Plugin-Web-CpanelJSON/actions) [![Coverage Status](http://codecov.io/github/kfly8/p5-Amon2-Plugin-Web-CpanelJSON/coverage.svg?branch=main)](https://codecov.io/github/kfly8/p5-Amon2-Plugin-Web-CpanelJSON?branch=main) [![MetaCPAN Release](https://badge.fury.io/pl/Amon2-Plugin-Web-CpanelJSON.svg)](https://metacpan.org/release/Amon2-Plugin-Web-CpanelJSON)\n# NAME\n\nAmon2::Plugin::Web::CpanelJSON - Cpanel::JSON::XS plugin\n\n# SYNOPSIS\n\n```perl\nuse Amon2::Lite;\nuse Cpanel::JSON::XS::Type;\nuse HTTP::Status qw(:constants);\n\n__PACKAGE__-\u003eload_plugins(qw/Web::CpanelJSON/);\n\nuse constant HelloWorld =\u003e {\n    message =\u003e JSON_TYPE_STRING,\n};\n\nget '/' =\u003e sub {\n    my $c = shift;\n    return $c-\u003erender_json(+{ message =\u003e 'HELLO!' }, HelloWorld, HTTP_OK);\n};\n\n__PACKAGE__-\u003eto_app();\n```\n\n# DESCRIPTION\n\nThis is a JSON plugin for Amon2.\nThe differences from Amon2::Plugin::Web::JSON are as follows.\n\n\\* Cpanel::JSON::XS::Type is available\n\n\\* HTTP status code can be specified\n\n\\* Flexible Configurations\n\n# METHODS\n\n- `$c-\u003erender_json($data, $json_spec, $status=200);`\n\n    Generate JSON `$data` and `$json_spec` and returns instance of [Plack::Response](https://metacpan.org/pod/Plack%3A%3AResponse).\n    `$json_spec` is a structure for JSON encoding defined in [Cpanel::JSON::XS::Type](https://metacpan.org/pod/Cpanel%3A%3AJSON%3A%3AXS%3A%3AType).\n\n# CONFIGURATION\n\n- json\n\n    Parameters of [Cpanel::JSON::XS](https://metacpan.org/pod/Cpanel%3A%3AJSON%3A%3AXS). Default is as follows:\n\n    ```perl\n    ascii =\u003e !!1,\n    ```\n\n    Any parameters can be set:\n\n    ```perl\n     __PACKAGE__-\u003eload_plugins(\n        'Web::CpanelJSON' =\u003e {\n            json =\u003e {\n                ascii     =\u003e 0,\n                utf8      =\u003e 1,\n                canonical =\u003e 1,\n            }\n        }\n    );\n    ```\n\n- secure\\_headers\n\n    Parameters of [HTTP::SecureHeaders](https://metacpan.org/pod/HTTP%3A%3ASecureHeaders). Default is as follows:\n\n    ```perl\n    content_security_policy           =\u003e \"default-src 'none'\",\n    strict_transport_security         =\u003e 'max-age=631138519',\n    x_content_type_options            =\u003e 'nosniff',\n    x_download_options                =\u003e undef,\n    x_frame_options                   =\u003e 'DENY',\n    x_permitted_cross_domain_policies =\u003e 'none',\n    x_xss_protection                  =\u003e '1; mode=block',\n    referrer_policy                   =\u003e 'no-referrer',\n    ```\n\n- json\\_escape\\_filter\n\n    Escapes JSON to prevent XSS. Default is as follows:\n\n    ```perl\n    '+' =\u003e '\\\\u002b',\n    '\u003c' =\u003e '\\\\u003c',\n    '\u003e' =\u003e '\\\\u003e',\n    ```\n\n- name\n\n    Name of method. Default: 'render\\_json'\n\n- unbless\\_object\n\n    Default: undef\n\n    This option is preprocessing coderef encoding an blessed object in JSON.\n    For example, the code using [Object::UnblessWithJSONSpec](https://metacpan.org/pod/Object%3A%3AUnblessWithJSONSpec) is as follows:\n\n    ```perl\n    use Object::UnblessWithJSONSpec ();\n\n    __PACKAGE__-\u003eload_plugins(\n        'Web::CpanelJSON' =\u003e {\n            unbless_object =\u003e \\\u0026Object::UnblessWithJSONSpec::unbless_with_json_spec,\n        }\n    );\n\n    ...\n\n    package Some::Object {\n        use Mouse;\n\n        has message =\u003e (\n            is =\u003e 'ro',\n        );\n    }\n\n    my $object = Some::Object-\u003enew(message =\u003e 'HELLO');\n    $c-\u003erender_json($object, { message =\u003e JSON_TYPE_STRING })\n    # =\u003e {\"message\":\"HELLO\"}\n    ```\n\n- status\\_code\\_field\n\n    Default: undef\n\n    It specify the field name of JSON to be embedded in the `X-API-Status` header.\n    Default is `undef`. If you set the `undef` to disable this `X-API-Status` header.\n\n    ```perl\n    __PACKAGE__-\u003eload_plugins(\n        'Web::CpanelJSON' =\u003e { status_code_field =\u003e 'status' }\n    );\n\n    ...\n\n    $c-\u003erender_json({ status =\u003e 200, message =\u003e 'ok' })\n    # send response header 'X-API-Status: 200'\n    ```\n\n    In general JSON API error code embed in a JSON by JSON API Response body.\n    But can not be logging the error code of JSON for the access log of a general Web Servers.\n    You can possible by using the `X-API-Status` header.\n\n- defence\\_json\\_hijacking\\_for\\_legacy\\_browser\n\n    Default: false\n\n# LICENSE\n\nCopyright (C) kfly8.\n\nThis library is free software; you can redistribute it and/or modify\nit under the same terms as Perl itself.\n\n# AUTHOR\n\nkfly8 \u003ckfly@cpan.org\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkfly8%2Fp5-amon2-plugin-web-cpaneljson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkfly8%2Fp5-amon2-plugin-web-cpaneljson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkfly8%2Fp5-amon2-plugin-web-cpaneljson/lists"}