aboutsummaryrefslogtreecommitdiff
path: root/captain
diff options
context:
space:
mode:
Diffstat (limited to 'captain')
-rw-r--r--captain/api.f9036
-rw-r--r--captain/response.f9090
-rw-r--r--captain/special.f908
3 files changed, 131 insertions, 3 deletions
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
diff --git a/captain/response.f90 b/captain/response.f90
index 2f48caa..cd1895a 100644
--- a/captain/response.f90
+++ b/captain/response.f90
@@ -47,6 +47,19 @@ module server_response
end type request
+ type, extends(request) :: titan_request
+
+ integer(kind=8)::size
+ character(len=:), pointer::mimetype
+ character(len=:), pointer::token
+
+ contains
+
+ procedure :: init_from_request => titan_request_init
+ procedure :: destroy => titan_request_destroy
+
+ end type titan_request
+
contains
subroutine request_init(self, str)
@@ -300,4 +313,81 @@ contains
end subroutine response_set_filename_using_allocation
+ function titan_get_request_value( full_location, label) result(p)
+ implicit none
+
+ character(*), intent(in)::full_location, label
+ character(len=:), pointer::p
+
+ integer::i, j, n, label_width
+
+ label_width = len_trim(label)
+
+ n = len_trim(full_location)
+ i = index(full_location, ";"//trim(label)//"=")
+ j = index(full_location(i+1:n), ";")
+ if(j<=0) then
+ j = n
+ else
+ j = j+i
+ end if
+ i = i + label_width + 2
+
+ allocate(character(len=(j-i+1))::p)
+ p = full_location(i:j)
+
+ end function titan_get_request_value
+
+ subroutine titan_request_init(self, regular_request)
+ implicit none
+
+ class(titan_request)::self
+ class(request), intent(inout)::regular_request
+
+ character(len=:), pointer::size_text
+ integer::i, ierr
+
+ self%url => regular_request%url
+ regular_request%url => null()
+
+ self%protocol => regular_request%protocol
+ regular_request%protocol => null()
+
+ self%server => regular_request%server
+ regular_request%server => null()
+
+ self%query_string => regular_request%query_string
+
+ i = index(regular_request%location, ";")
+ allocate(character(len=(i-1)) :: self%location)
+ self%location = regular_request%location(1:i-1)
+
+ size_text => titan_get_request_value(regular_request%location, "size")
+ read(size_text, *, iostat=ierr) self%size
+ if(ierr <= 0) then
+ self%size = 0
+ end if
+ deallocate(size_text)
+
+ self%mimetype => titan_get_request_value(regular_request%location, "mime")
+ self%token => titan_get_request_value(regular_request%location, "token")
+
+ end subroutine titan_request_init
+
+ subroutine titan_request_destroy(self)
+ implicit none
+
+ class(titan_request)::self
+
+ if(associated(self%mimetype)) then
+ deallocate(self%mimetype)
+ end if
+ if(associated(self%token)) then
+ deallocate(self%token)
+ end if
+
+ call request_destroy(self)
+
+ end subroutine titan_request_destroy
+
end module server_response
diff --git a/captain/special.f90 b/captain/special.f90
index 1bbf220..3850d3f 100644
--- a/captain/special.f90
+++ b/captain/special.f90
@@ -50,4 +50,12 @@ contains
end function get_instructions_static_filename
+ function get_task_result_static_filename(job_id, task_num) result(res)
+ implicit none
+
+
+
+
+ end function get_task_result_static_filename
+
end module special_filenames