From d0eee0c992254a175a96c0ce702fe257762233af Mon Sep 17 00:00:00 2001 From: Rudis Muiznieks Date: Thu, 23 Jul 2020 18:45:16 -0500 Subject: [PATCH] clean up minisign source during docker build --- Dockerfile | 4 +++- server.pl | 64 +++++++++++++++++++++++++++--------------------------- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/Dockerfile b/Dockerfile index c4b5d74..fbc81c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,9 @@ run mkdir -p /tmp/minisign && \ make && \ make install -run mkdir -p /opt/data/plans +run rm -rf /tmp/minisign && \ + mkdir -p /opt/data/plans + copy schema.sql /opt/data run cat /opt/data/schema.sql | sqlite3 /opt/data/users.db run rm /opt/data/schema.sql diff --git a/server.pl b/server.pl index 78f3edf..de822da 100644 --- a/server.pl +++ b/server.pl @@ -99,6 +99,38 @@ if (defined $ENV{'LOCAL_DOMAINS'}) { ################# # Request Routing ################# + # + my $routes = [ + { + path => qr/^\/plan\/([^\/]{$minimum_email_length,$maximum_email_length})$/, + methods => { + GET => {handler => \&get_plan, valid_types => ['application/json', 'text/plain']}, + HEAD => {handler => \&get_plan, valid_types => ['application/json', 'text/plain']}, + PUT => {handler => \&update_plan, valid_types => ['application/json']} + } + }, + { + path => qr/^\/token$/, + methods => { + GET => {handler => \&get_token, valid_types => ['application/json']}, + DELETE => {handler => \&delete_token, valid_types => ['application/json']} + } + }, + { + path => qr/^\/users\/([^\/]{$minimum_email_length,$maximum_email_length})\/pwchange$/, + methods => { + GET => {handler => \&get_pwtoken, valid_types => ['application/json']}, + PUT => {handler => \&update_password, valid_types => ['application/json']} + } + }, + { + path => qr/^\/users\/([^\/]{$minimum_email_length,$maximum_email_length})$/, + methods => { + POST => {handler => \&create_user, valid_types => ['application/json']}, + PUT => {handler => \&validate_email, valid_types => ['application/json']} + } + }, + ]; sub handle_request { my ($self, $cgi) = @_; @@ -124,38 +156,6 @@ if (defined $ENV{'LOCAL_DOMAINS'}) { $cgi->param('json-body', {}); } - my $routes = [ - { - path => qr/^\/plan\/([^\/]{$minimum_email_length,$maximum_email_length})$/, - methods => { - GET => {handler => \&get_plan, valid_types => ['application/json', 'text/plain']}, - HEAD => {handler => \&get_plan, valid_types => ['application/json', 'text/plain']}, - PUT => {handler => \&update_plan, valid_types => ['application/json']} - } - }, - { - path => qr/^\/token$/, - methods => { - GET => {handler => \&get_token, valid_types => ['application/json']}, - DELETE => {handler => \&delete_token, valid_types => ['application/json']} - } - }, - { - path => qr/^\/users\/([^\/]{$minimum_email_length,$maximum_email_length})\/pwchange$/, - methods => { - GET => {handler => \&get_pwtoken, valid_types => ['application/json']}, - PUT => {handler => \&update_password, valid_types => ['application/json']} - } - }, - { - path => qr/^\/users\/([^\/]{$minimum_email_length,$maximum_email_length})$/, - methods => { - POST => {handler => \&create_user, valid_types => ['application/json']}, - PUT => {handler => \&validate_email, valid_types => ['application/json']} - } - }, - ]; - eval { util_log("REQ $req_id $method $path");