mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-26 09:59:01 +00:00
Some cleanup and implement the X-Protobuf-Schema header
This commit is contained in:
parent
5b4472ab56
commit
2901f773a4
@ -343,6 +343,7 @@ void handleAPIv1FromRadio(HTTPRequest *req, HTTPResponse *res)
|
|||||||
res->setHeader("Content-Type", "application/x-protobuf");
|
res->setHeader("Content-Type", "application/x-protobuf");
|
||||||
res->setHeader("Access-Control-Allow-Origin", "*");
|
res->setHeader("Access-Control-Allow-Origin", "*");
|
||||||
res->setHeader("Access-Control-Allow-Methods", "PUT, GET");
|
res->setHeader("Access-Control-Allow-Methods", "PUT, GET");
|
||||||
|
res->setHeader("X-Protobuf-Schema", "https://raw.githubusercontent.com/meshtastic/Meshtastic-protobufs/master/mesh.proto");
|
||||||
|
|
||||||
uint8_t txBuf[MAX_STREAM_BUF_SIZE];
|
uint8_t txBuf[MAX_STREAM_BUF_SIZE];
|
||||||
uint32_t len = 1;
|
uint32_t len = 1;
|
||||||
@ -380,19 +381,14 @@ void handleAPIv1ToRadio(HTTPRequest *req, HTTPResponse *res)
|
|||||||
|
|
||||||
// Status code is 200 OK by default.
|
// Status code is 200 OK by default.
|
||||||
|
|
||||||
if (req->getMethod() != "OPTIONS") {
|
res->setHeader("Content-Type", "application/x-protobuf");
|
||||||
res->setHeader("Content-Type", "application/x-protobuf");
|
|
||||||
} else {
|
|
||||||
res->setHeader("Content-Type", "application/x-protobuf");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
res->setHeader("Access-Control-Allow-Headers", "Content-Type");
|
res->setHeader("Access-Control-Allow-Headers", "Content-Type");
|
||||||
res->setHeader("Access-Control-Allow-Origin", "*");
|
res->setHeader("Access-Control-Allow-Origin", "*");
|
||||||
res->setHeader("Access-Control-Allow-Methods", "PUT, OPTIONS");
|
res->setHeader("Access-Control-Allow-Methods", "PUT, OPTIONS");
|
||||||
|
res->setHeader("X-Protobuf-Schema", "https://raw.githubusercontent.com/meshtastic/Meshtastic-protobufs/master/mesh.proto");
|
||||||
|
|
||||||
if (req->getMethod() == "OPTIONS") {
|
if (req->getMethod() == "OPTIONS") {
|
||||||
res->setStatusCode(204);
|
res->setStatusCode(204); // Success with no content
|
||||||
res->print("");
|
res->print("");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user