From bff06af2176e2f2813482b4fa7b4096a9982999b Mon Sep 17 00:00:00 2001 From: Jeffrey Armstrong Date: Fri, 2 Apr 2021 16:37:36 -0400 Subject: More work on titan request handling, including a titan request derived type --- captain/api.f90 | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'captain/api.f90') diff --git a/captain/api.f90 b/captain/api.f90 index 48cae8a..8b6890d 100644 --- a/captain/api.f90 +++ b/captain/api.f90 @@ -50,6 +50,7 @@ contains resp%code = GEMINI_CODE_SUCCESS call resp%set_body_contents(RESPONSE_JSON_OKAY) + resp%body_mimetype = "application/json" ! Checkin - /api/player/{name}/checkin.json else if(trim(req%component(2)) == "player" .and. trim(req%component(4)) == "checkin.json") then @@ -76,8 +77,35 @@ contains use server_response implicit none - type(request), intent(in)::req + type(titan_request), intent(in)::req type(response)::resp + + character(len=:), pointer::fullpath + + fullpath => null() + + ! Task - "/api/player/{name}/job/{jobid}/task/{task num}" + if(trim(req%component(2)) == "player" .and. & + trim(req%component(4)) == "job" .and. & + trim(req%component(6)) == "task") then + + fullpath => + + end if + + if(associated(fullpath)) then + + resp%code = GEMINI_CODE_SUCCESS + call resp%set_body_contents(RESPONSE_JSON_OKAY) + resp%body_mimetype = "application/json" + + else + + resp%code = GEMINI_CODE_PERMFAIL + + end if + + end function api_request_titan @@ -85,13 +113,15 @@ contains use server_response implicit none - type(request), intent(in)::req + type(request)::req + type(titan_request)::titan_req type(response)::resp if(req%protocol == "gemini") then resp = api_request_gemini(req) else if(req%protocol == "titan") then - resp = api_request_titan(req) + call titan_req%init_from_request(req) + resp = api_request_titan(titan_req) end if end function api_request -- cgit v1.2.3