The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

App::MBUtiny::Collector::Server - MBUtiny collector server

VERSION

Version 1.01

SYNOPSIS

    use CGI;
    use App::MBUtiny::Collector::Server "/mbutiny";

    my $q = new CGI;
    my $server = new App::MBUtiny::Collector::Server(
        project => "MBUtiny",
        ident   => "mbutiny",
        log     => "on",
        logfd   => fileno(STDERR),
    );
    $server->status or die($server->error);
    print $server->call($q->request_method, $q->request_uri, $q)
      or die($server->error);

DESCRIPTION

MBUtiny collector server

This class provides WWW::MLite REST server methods for MBUtiny collector

See collector.cgi.sample file for example

METHODS

WWW::MLite methods

GET /mbutiny

    curl -v --raw http://localhost/mbutiny

    > GET /mbutiny HTTP/1.1
    > Host: localhost
    > User-Agent: curl/7.62.0
    > Accept: */*
    >
    < HTTP/1.1 200 OK
    < Date: Wed, 19 Jun 2019 10:57:31 GMT
    < Server: Apache/2.2.25 (Win32) mod_ssl/2.2.25 OpenSSL/0.9.8y mod_perl/2.0.8 Perl/v5.16.3
    < Connection: close
    < Content-Length: 214
    < Content-Type: application/json; charset=utf-8
    <
    {
       "dsn" : "dbi:SQLite:dbname=/var/lib/mbutiny/mbutiny.db",
       "status" : 1,
       "name" : "check",
       "error" : "",
       "method" : "GET",
       "path" : "/mbutiny",
       "description" : "Check collectors"
    }

    curl -v --raw http://localhost/mbutiny/foo

    > GET /mbutiny/foo HTTP/1.1
    > Host: localhost
    > User-Agent: curl/7.58.0
    > Accept: */*
    >
    < HTTP/1.1 200 OK
    < Date: Sat, 22 Jun 2019 10:29:26 GMT
    < Server: Apache/2.4.29 (Ubuntu)
    < Connection: close
    < Content-Length: 556
    < Content-Type: application/json; charset=utf-8
    <
    {
       "name" : "foo",
       "error" : "",
       "file" : null,
       "status" : 1,
       "time" : 0.0073,
       "info" : {
          "comment" : "Local storages...",
          "sha1" : "4200f422b425967ca2cb278cf311edeb74ecdde1",
          "addr" : "127.0.0.1",
          "file" : "foo-2019-06-22.tar.gz",
          "type" : 1,
          "status" : 1,
          "time" : 1561194766,
          "md5" : "008413f90584f4af5d5a49c7c0ec64c2",
          "id" : 13,
          "size" : 501,
          "name" : "foo",
          "error" : ""
       }
    }

GET /mbutiny/list

    curl -v --raw http://localhost/mbutiny/list?name=foo

    > GET /mbutiny/list HTTP/1.1
    > Host: localhost
    > User-Agent: curl/7.50.1
    > Accept: */*
    >
    < HTTP/1.1 200 OK
    < Date: Fri, 31 May 2019 05:41:34 GMT
    < Server: Apache/2.4.18 (Ubuntu)
    < Connection: close
    < Content-Length: 16
    < Content-Type: text/plain
    <
    {
       "time" : 0.0012,
       "list" : [...],
       "status" : 1,
       "error" : ""
    }

GET /mbutiny/report

    curl -v --raw http://localhost/mbutiny/report?start=1561799700

    > GET /mbutiny/report HTTP/1.1
    > Host: localhost
    > User-Agent: curl/7.50.1
    > Accept: */*
    >
    < HTTP/1.1 200 OK
    < Date: Fri, 31 May 2019 05:41:34 GMT
    < Server: Apache/2.4.18 (Ubuntu)
    < Connection: close
    < Content-Length: 16
    < Content-Type: text/plain
    <
    {
       "time" : 0.0012,
       "report" : [...],
       "status" : 1,
       "error" : ""
    }

POST /mbutiny

    curl -v -d '{ "type": 1, "name": "foo", "file": "foo", "size": 501, "md5": "3a5fb8a1e0564eed5a6f5c4389ec5fa0", "sha1": "22d12324fa2256e275761b55d5c063b8d9fc3b95", "status": 1, "error": "", "comment": "Test external fixup!"}' --raw -H "Content-Type: application/json" http://localhost/mbutiny

    > POST /mbutiny HTTP/1.1
    > Host: localhost
    > User-Agent: curl/7.50.1
    > Accept: */*
    > Content-Type: application/json
    > Content-Length: 27
    >
    < HTTP/1.1 200 OK
    < Date: Thu, 20 Jun 2019 15:03:34 GMT
    < Server: Apache/2.4.18 (Ubuntu)
    < Connection: close
    < Content-Length: 27
    < Content-Type: text/plain; charset=utf-8
    <

DELETE /mbutiny/NAME

    curl -v --raw -X DELETE http://localhost/mbutiny/NAME?file=name&type=1

    > DELETE /mbutiny/NAME?file=name HTTP/1.1
    > Host: localhost
    > User-Agent: curl/7.58.0
    > Accept: */*
    >
    < HTTP/1.1 204 No Content
    < Date: Fri, 21 Jun 2019 21:40:36 GMT
    < Server: Apache/2.4.29 (Ubuntu)
    < Connection: close
    < Content-Type: text/plain
    <

INTERNAL METHODS

again

The CTK method for classes extension

See "again" in CTK

dbi

Returns App::MBUtiny::Collector::DBI object

middleware

The WWW::MLite method for input data preparing

response

The WWW::MLite method for output data preparing

serializer

Returns current serializer object

See CTK::Serializer

HISTORY

See Changes file

TO DO

See TODO file

SEE ALSO

App::MBUtiny, WWW::MLite, App::MBUtiny::Collector::DBI

AUTHOR

Serż Minus (Sergey Lepenkov) http://www.serzik.com <abalama@cpan.org>

COPYRIGHT

Copyright (C) 1998-2019 D&D Corporation. All Rights Reserved

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See LICENSE file and https://dev.perl.org/licenses/