diff options
author | Jeffrey Armstrong <jeff@approximatrix.com> | 2021-05-11 20:09:08 -0400 |
---|---|---|
committer | Jeffrey Armstrong <jeff@approximatrix.com> | 2021-05-11 20:09:08 -0400 |
commit | a25527272916f342875809d7c3606ba0ebd350b4 (patch) | |
tree | 4a4767bd07d181509535a2cc397a5a057b3503ef /captain/response.f90 | |
parent | 0f31824a5e4969d56d88678e05274163be3d8b77 (diff) | |
download | levitating-a25527272916f342875809d7c3606ba0ebd350b4.tar.gz levitating-a25527272916f342875809d7c3606ba0ebd350b4.zip |
Moved some command handling into requtils to share with web and gemini modes. Started work on handling post requests to add players.
Diffstat (limited to 'captain/response.f90')
-rw-r--r-- | captain/response.f90 | 33 |
1 files changed, 31 insertions, 2 deletions
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 |