Rewrite API (#825)

he /world/Topic() API has been rewritten.

General function:

The API is initialized upon roundstart and generates a list of possible api requests from /code/datums/api.dm
Once a request is made the following checks are performed:
If a query parameter is set (the function that should be called)
If the ip is ratelimited (or rate-limit-whitelisted)
The query is authenticated against the db using ip, function and key
If these checks pass, it is validated that the api command exists
Then the api command is called, all supplied params are passed through
Each API function returns 1 no matter if it failed or succeded
Additional info is provided in the statuscode, response and data vars
The statuscode, response and data are send back to the caller (through list2params)
The data var is json encoded before sending it back
This is not backward compatible to the current API
Current API Clients need to be updated
This commit is contained in:
Werner
2016-09-04 21:41:44 +02:00
committed by skull132
parent 2118078422
commit fb25382405
10 changed files with 911 additions and 437 deletions
+5 -5
View File
@@ -229,20 +229,20 @@ Allow admins to set players to be able to respawn/bypass 30 min wait, without th
Ccomp's first proc.
*/
/client/proc/get_ghosts(var/notify = 0,var/what = 2)
proc/get_ghosts(var/notify = 0,var/what = 2, var/client/C = null)
// what = 1, return ghosts ass list.
// what = 2, return mob list
var/list/mobs = list()
var/list/ghosts = list()
var/list/sortmob = sortAtom(mob_list) // get the mob list.
/var/any=0
var/any=0
for(var/mob/dead/observer/M in sortmob)
mobs.Add(M) //filter it where it's only ghosts
any = 1 //if no ghosts show up, any will just be 0
if(!any)
if(notify)
src << "There doesn't appear to be any ghosts for you to select."
if(notify && C)
C << "There doesn't appear to be any ghosts for you to select."
return
for(var/mob/M in mobs)
@@ -260,7 +260,7 @@ Ccomp's first proc.
set desc = "Let's the player bypass the 30 minute wait to respawn or allow them to re-enter their corpse."
if(!holder)
src << "Only administrators may use this command."
var/list/ghosts= get_ghosts(1,1)
var/list/ghosts = get_ghosts(1,1,src)
var/target = input("Please, select a ghost!", "COME BACK TO LIFE!", null, null) as null|anything in ghosts
if(!target)