WWW-Suffit-API

 view release on metacpan or  search on metacpan

lib/WWW/Suffit/Server/API.pm  view on Meta::CPAN

=head1 NAME

WWW::Suffit::Server::API - The Suffit API controller

=head1 SYNOPSIS

    use WWW::Suffit::Server::API;

=head1 DESCRIPTION

The Suffit API controller

=head1 METHODS

List of internal methods

=head2 api

See L</"GET /api">

=head2 check

See L</"GET /api/check">

=head2 is_connected

This method connects to the authorization database and returns the connection status

    my $r = $app->routes->under('/')
        ->to('API#is_connected')
        ->name('__authdb');

=head1 API METHODS

List of API methods

=head2 GET /api

This method returns general statistics of the API server, available only after authorization

    # curl -v -H "Authorization: Bearer eyJh...s5aM" \
      https://localhost:8695/api

    > GET /api HTTP/1.1
    > Host: localhost:8695
    > User-Agent: curl/7.68.0
    > Accept: */*
    > Authorization: Bearer eyJh...s5aM
    >
    < HTTP/1.1 200 OK
    < Content-Length: 3188
    < Content-Type: application/json;charset=UTF-8
    < Date: Wed, 14 Aug 2024 08:05:01 GMT
    < Server: OWL/1.11
    < Vary: Accept-Encoding
    <
    {
      "algorithms": [ "MD5", "SHA1", "SHA224", "SHA256", "SHA384", "SHA512" ],
      "api_version": "1.02",
      "authdb": {
        "ds": "mysql://localhost/authdb?mysql_auto_reconnect=1&mysql_enable_utf8=1",
        "error": "",
        "schver": "1.01",
        "status": true
      },
      "base_url": "https://localhost:8695",
      "code": "E0000",
      "csrf": "...",
      "datetime": "2024-08-14T08:05:01Z",
      "elapsed": 0.000289,
      "entities": {
        "Default": [ "Allow", "Deny" ],
        "Env": [
          "LANG", "LOGNAME", "MOJO_MODE", "USER", "USERNAME",
          "USR1", "USR2", "USR3"
        ],
        "Header": [
          "Accept", "Host", "User-Agent", "X-Token", "X-Auth",
          "X-Usr1", "X-Usr2", "X-Usr3" ],
        "Host": [ "Host", "IP" ],
        "User/Group": [ "User", "Group", "Valid-User" ]
      },
      "files": {
        "datadir": "/tmp/data",
        "documentroot": "/tmp/public",
        "home": "/tmp/www",
        "homedir": "/tmp/www",
        "logfile": null,
        "render_paths": [
          "/tmp/templates", "/tmp/public", "/tmp/www"
        ],
        "static_paths": [ "/tmp/public", "/tmp/www" ],
        "tempdir": "/tmp"
      },
      "generated": 1723622701,
      "is_authorized": true,
      "message": "Ok",
      "methods": [
        "CONNECT", "OPTIONS", "HEAD", "GET", "POST", "PUT",
        "PATCH", "DELETE", "TRACE", "ANY", "MULTI"
      ],
      "namespaces": [
        "WWW::OWL::Server::Controller",
        "WWW::OWL::Server",
        "WWW::Suffit::Server"
      ],
      "operators": [
        { "name": "eq", "operator": "==", "title": "equal to" },
        { "name": "ne", "operator": "!=", "title": "not equal" },
        { "name": "gt", "operator": ">", "title": "greater than" },
        { "name": "lt", "operator": "<", "title": "less than" },
        { "name": "ge", "operator": ">=", "title": "greater than or equal to" },
        { "name": "le", "operator": "<=", "title": "less than or equal to" },
        { "name": "re", "operator": "=~", "title": "regexp match" },
        { "name": "rn", "operator": "!~", "title": "regexp not match" }
      ],
      "project": "XXX",
      "providers": [ "Default", "User/Group", "Host", "Env", "Header" ],
      "public_key": "-----BEGIN RSA PUBLIC KEY-----...",
      "remote_addr": "127.0.0.1",
      "requestid": "MsojYEwbL8Nx",



( run in 2.190 seconds using v1.01-cache-2.11-cpan-97f6503c9c8 )