fix missing package name; move get_help to module (route 1/9)

parent 7684d8a0
package checks;
use strict;
use warnings;
......
......@@ -17,7 +17,7 @@ use database;
#use routes::locksub;
#use routes::chgkey;
#use routes::listsub;
#use routes::help;
use routes::help;
#use routes::updatesub;
#use routes::clearsub;
......@@ -34,7 +34,7 @@ my %routes = (
"/lock" => \&lock_subdomain,
"/chgkey" => \&chgkey_subdomain,
"/list" => \&list_subdomains,
"/help" => \&get_help,
"/help" => \&help::get_help,
"/update" => \&update_ddns,
"/clear" => \&clear_ddns,
);
......@@ -237,34 +237,6 @@ sub modify_subdomain {
}
}
sub get_help {
my $req = shift;
my $c_method = check_method($req);
if (!defined $c_method) {
my $c_params = check_params($req, ("key"));
if (!defined $c_params && $req->body_parameters->get("key") eq $conf::admin_key) {
my $res = $req->new_response(200, [],
"-- Wormhole DynDNS Admin help --\n" .
"[POST] /create <key> <subdomain> - Create a subdomain with a random key\n" .
"[POST] /modify <key> <subdomain> <ip4/ip6> - Manually assign an address to a subdomain\n" .
"[POST] /delete <key> <subdomain> - Delete a subdomain\n" .
"[POST] /lock <key> <subdomain> <1/0> - Modify lock state of a subdomain\n" .
"[POST] /chgkey <key> <subdomain> - Generate a new random key for a subdomain\n" .
"[POST] /list <key> <subdomain> - List all subdomains, their ips and last update\n" .
"[POST] /help <key> - Display admin help\n");
return $res->finalize;
}
}
my $res = $req->new_response(200, [],
"-- Wormhole DynDNS help --\n" .
"[POST] /update <key> <subdomain> - Update your subdomain\n" .
"[POST] /clear <key> <subdomain> - Clear your subdomain\n" .
"[ GET] /help - Display help\n");
return $res->finalize;
}
sub update_ddns {
my $req = shift;
......
package help;
use strict;
use warnings;
use lib "..";
use conf;
use checks qw(check_params check_method);
sub get_help {
my $req = shift;
my $c_method = check_method($req);
if (!defined $c_method) {
my $c_params = check_params($req, ("key"));
if (!defined $c_params && $req->body_parameters->get("key") eq $conf::admin_key) {
my $res = $req->new_response(200, [],
"-- Wormhole DynDNS Admin help --\n" .
"[POST] /create <key> <subdomain> - Create a subdomain with a random key\n" .
"[POST] /modify <key> <subdomain> <ip4/ip6> - Manually assign an address to a subdomain\n" .
"[POST] /delete <key> <subdomain> - Delete a subdomain\n" .
"[POST] /lock <key> <subdomain> <1/0> - Modify lock state of a subdomain\n" .
"[POST] /chgkey <key> <subdomain> - Generate a new random key for a subdomain\n" .
"[POST] /list <key> <subdomain> - List all subdomains, their ips and last update\n" .
"[POST] /help <key> - Display admin help\n");
return $res->finalize;
}
}
my $res = $req->new_response(200, [],
"-- Wormhole DynDNS help --\n" .
"[POST] /update <key> <subdomain> - Update your subdomain\n" .
"[POST] /clear <key> <subdomain> - Clear your subdomain\n" .
"[ GET] /help - Display help\n");
return $res->finalize;
}
1;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment