Skip to content

Commit

Permalink
added POST to proxies endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
computergeek1507 committed Oct 30, 2023
1 parent f783278 commit 20aab09
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
15 changes: 15 additions & 0 deletions www/api/controllers/proxies.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ function LoadProxyList()
return $proxies;
}

function PostProxies()
{
$proxies = $_POST;
if (!empty($proxies)) {
WriteProxyFile($proxies);

//Trigger a JSON Configuration Backup
GenerateBackupViaAPI('Proxies were added.');

return json($proxies);
} else {
http_response_code(400); // Bad Request
}
}

function WriteProxyFile($proxies)
{
global $settings;
Expand Down
25 changes: 25 additions & 0 deletions www/api/endpoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -2050,6 +2050,31 @@
"192.168.1.146",
"192.168.1.148"
]
},
"POST": {
"desc": "Post a list of IP addresses that this FPP instance can proxy",
"output": [
"192.168.1.2",
"192.168.1.146",
"192.168.1.148"
]
}
}
},
{
"endpoint": "proxies/:ProxyIp",
"methods": {
"POST": {
"desc": "Add an IP address to this FPP instance can proxy",
"output": [
"192.168.1.2"
]
},
"DELETE": {
"desc": "Delete an IP address from FPP proxy list",
"output": [

]
}
}
},
Expand Down
1 change: 1 addition & 0 deletions www/api/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
// which are added after the above endpoints via addPluginEndpoints() below.

dispatch_get('/proxies', 'GetProxies');
dispatch_post('/proxies', 'PostProxies');
dispatch_post('/proxies/:ProxyIp', 'AddProxy');
dispatch_delete('/proxies/:ProxyIp', 'DeleteProxy');

Expand Down

0 comments on commit 20aab09

Please sign in to comment.