mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-04 00:36:14 +00:00
http: add /config
This commit is contained in:
parent
b46dc664c6
commit
f7acd1e819
31
openapi.yml
31
openapi.yml
@ -13,6 +13,37 @@ servers:
|
|||||||
port:
|
port:
|
||||||
default: "8000"
|
default: "8000"
|
||||||
paths:
|
paths:
|
||||||
|
/config:
|
||||||
|
get:
|
||||||
|
summary: describes server configuration
|
||||||
|
description: |
|
||||||
|
An overview over the configuration currently
|
||||||
|
used by this server.
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
content:
|
||||||
|
"application/json":
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
example: "my awesome beammp server"
|
||||||
|
description:
|
||||||
|
type: string
|
||||||
|
example: "join!"
|
||||||
|
max_players:
|
||||||
|
type: integer
|
||||||
|
example: 7
|
||||||
|
max_cars:
|
||||||
|
type: integer
|
||||||
|
example: 2
|
||||||
|
map:
|
||||||
|
type: string
|
||||||
|
example: "/levels/gridmap_v2/info.json"
|
||||||
|
private:
|
||||||
|
type: boolean
|
||||||
/ready:
|
/ready:
|
||||||
get:
|
get:
|
||||||
summary: whether the server has started fully
|
summary: whether the server has started fully
|
||||||
|
14
src/Http.cpp
14
src/Http.cpp
@ -157,6 +157,20 @@ void Http::Server::THttpServerInstance::operator()() try {
|
|||||||
HttpLibServerInstance->Get("/", [](const httplib::Request&, httplib::Response& res) {
|
HttpLibServerInstance->Get("/", [](const httplib::Request&, httplib::Response& res) {
|
||||||
res.set_content("<!DOCTYPE html><article><h1>Hello World!</h1><section><p>BeamMP Server can now serve HTTP requests!</p></section></article></html>", "text/html");
|
res.set_content("<!DOCTYPE html><article><h1>Hello World!</h1><section><p>BeamMP Server can now serve HTTP requests!</p></section></article></html>", "text/html");
|
||||||
});
|
});
|
||||||
|
HttpLibServerInstance->Get(API_V1 "/config", [](const httplib::Request&, httplib::Response& res) {
|
||||||
|
res.status = 200;
|
||||||
|
res.set_content(json {
|
||||||
|
{ "name", Application::Settings.ServerName },
|
||||||
|
{ "description", Application::Settings.ServerDesc },
|
||||||
|
{ "max_players", Application::Settings.MaxPlayers },
|
||||||
|
{ "max_cars", Application::Settings.MaxCars },
|
||||||
|
{ "map", Application::Settings.MapName },
|
||||||
|
{ "private", Application::Settings.Private },
|
||||||
|
}
|
||||||
|
.dump(),
|
||||||
|
"application/json");
|
||||||
|
});
|
||||||
|
|
||||||
HttpLibServerInstance->Get(API_V1 "/ready", [](const httplib::Request&, httplib::Response& res) {
|
HttpLibServerInstance->Get(API_V1 "/ready", [](const httplib::Request&, httplib::Response& res) {
|
||||||
auto Statuses = Application::GetSubsystemStatuses();
|
auto Statuses = Application::GetSubsystemStatuses();
|
||||||
bool Started = true;
|
bool Started = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user