: localhost
Content-Type: application/json
{
"method":"create"
}
## response
HTTP/1.1 201 Created
Content-Type: application/json;charset=UTF-8
Cache-Control: no-stor
Type: application/json
{
"method":"read",
"id":"81c8feb9b54f632823fafea71966b5f89ad5cc92"
}
## response
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
cation/json
{
"method":"update",
"id":"81c8feb9b54f632823fafea71966b5f89ad5cc92",
"type":"hotp"
}
## response
HTTP/1.1 200 OK
Content-Type: application/json;charse
=> 1;
use Try::Tiny qw/try catch/;
use Plack::Request;
use Params::Validate;
use JSON::XS qw/decode_json encode_json/;
use Convert::Base32 qw/encode_base32/;
use Net::OATH::Server::Lite::Error;
use
s ($request->method eq q{POST});
# content MUST be JSON
my $content = {};
eval {
$content = decode_json($request->content) if $request->content;
};
Content-Type" => "application/json;charset=UTF-8",
"Cache-Control" => "no-store",
"Pragma" => "no-cache" ],
[ encode_json($params) ]);
} catch {
=> 1;
use Try::Tiny qw/try catch/;
use Plack::Request;
use Params::Validate;
use JSON::XS qw/decode_json encode_json/;
use Net::OATH::Server::Lite::Login;
use Net::OATH::Server::Lite::Error;
sub n
s ($request->method eq q{POST});
my $params;
eval {
$params = decode_json($request->content);
};
Net::OATH::Server::Lite::Error->throw() unless $params;
t-Type" => "application/json;charset=UTF-8",
"Cache-Control" => "no-store",
"Pragma" => "no-cache" ],
[ encode_json($response_params) ]);
:Lite::Error;
# default error
# HTTP/1.1 400 Bad Request
# Content-Type: application/json;charset=UTF-8
# Cache-Control: no-store
# Pragma: no-cache
#
# {
# "error":
->throw() if ...
# custom error
# HTTP/1.1 404 Not Found
# Content-Type: application/json;charset=UTF-8
# Cache-Control: no-store
# Pragma: no-cache
#
# {
# "error":