Pārlūkot izejas kodu

add /authenticated and /status routes

George Baugh 5 mēneši atpakaļ
vecāks
revīzija
3ce7443f36
1 mainītis faili ar 23 papildinājumiem un 0 dzēšanām
  1. 23 0
      lib/TCMS.pm

+ 23 - 0
lib/TCMS.pm

@@ -177,6 +177,29 @@ sub _routes ( $data = {} ) {
         callback => \&robots,
     };
 
+    # Special 'am I authenticated' route for nginx
+    $routes{'/authenticated'} = {
+        method => 'GET',
+        nocache => 1,
+        noindex => 1,
+        callback => sub {
+            my ($query) = @_;
+            return $query->{tpsgi}->ok($query) if $query->{user};
+            return $query->{tpsgi}->forbidden($query);
+        },
+    };
+
+    # Heartbeat route
+    $routes{'/status'} = {
+        method => 'GET',
+        nocache => 1,
+        noindex => 1,
+        callback => sub {
+            my ($query) = @_;
+            return $query->{tpsgi}->ok($query);
+        },
+    };
+
     # The Various aliases for directory indices
     foreach my $index (qw{ / /index.html /index.htm}) {
         $routes{$index} = $routes{'/index'} unless exists $routes{$index};