From a25527272916f342875809d7c3606ba0ebd350b4 Mon Sep 17 00:00:00 2001 From: Jeffrey Armstrong Date: Tue, 11 May 2021 20:09:08 -0400 Subject: Moved some command handling into requtils to share with web and gemini modes. Started work on handling post requests to add players. --- captain/response.f90 | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'captain/response.f90') diff --git a/captain/response.f90 b/captain/response.f90 index 610b070..dfce5e7 100644 --- a/captain/response.f90 +++ b/captain/response.f90 @@ -63,6 +63,7 @@ implicit none character(len=:), pointer::location => null() character(len=:), pointer::page => null() character(len=:), pointer::query_string => null() + character(len=4)::method = "GET" contains @@ -73,6 +74,8 @@ implicit none procedure :: path_component_int => request_component_int procedure :: path_starting_with_component => request_component_starting_with procedure :: component => request_component_func + procedure :: is_get => request_is_get + procedure :: is_post => request_is_post end type request @@ -94,13 +97,14 @@ implicit none contains - subroutine request_init(self, str, server_explicit, protocol_explicit) + subroutine request_init(self, str, server_explicit, protocol_explicit, method) use logging + use utilities, only: toupper implicit none class(request) :: self character(*), intent(in)::str - character(*), intent(in), optional::server_explicit, protocol_explicit + character(*), intent(in), optional::server_explicit, protocol_explicit, method character(len=:), allocatable::temppage integer::i, j, n @@ -179,6 +183,11 @@ contains self%page = temppage end if deallocate(temppage) + + if(present(method)) then + self%method = method + call toupper(self%method) + end if end subroutine request_init @@ -328,6 +337,26 @@ contains end subroutine request_last_component + function request_is_get(self) result(res) + implicit none + + class(request)::self + logical::res + + res = (self%method == "GET") + + end function request_is_get + + function request_is_post(self) result(res) + implicit none + + class(request)::self + logical::res + + res = (self%method == "POST") + + end function request_is_post + subroutine request_destroy(self) implicit none -- cgit v1.2.3