浏览代码

add generic 200 ok handler

George Baugh 5 月之前
父节点
当前提交
73932a5d1a
共有 1 个文件被更改,包括 13 次插入 和 0 次删除
  1. 13 0
      lib/TPSGI.pm

+ 13 - 0
lib/TPSGI.pm

@@ -487,6 +487,19 @@ sub see_also {
     return [ 303, [ "Location" => $to, "Content-Length" => 0 ], [''] ];
 }
 
+=head2 ok
+
+Return a generic HTTP 200 OK
+
+=cut
+
+sub ok {
+    my ( $self, $query, $body ) = @_;
+    $self->INFO("$query->{method} 200 $query->{fullpath}");
+    $body //= 'Ok';
+    return _generic( $body, 200 );
+}
+
 =head2 notfound, forbidden, badrequest, toolong, error
 
 If you need to return these HTTP errors, return these within a route: