MCPcopy Create free account
hub / github.com/ArduPilot/ArduRemoteID / handle

Method handle

RemoteIDModule/webinterface.cpp:32–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30 }
31
32 bool handle(WebServer& server, HTTPMethod requestMethod, String requestUri) {
33 if (requestUri == "/") {
34 requestUri = "/index.html";
35 }
36 String uri = "web" + requestUri;
37 Serial.printf("handle: '%s'\n", requestUri.c_str());
38
39 // work out content type
40 const char *content_type = "text/html";
41 const struct {
42 const char *extension;
43 const char *content_type;
44 } extensions[] = {
45 { ".js", "text/javascript" },
46 { ".jpg", "image/jpeg" },
47 { ".png", "image/png" },
48 { ".css", "text/css" },
49 };
50 for (const auto &e : extensions) {
51 if (uri.endsWith(e.extension)) {
52 content_type = e.content_type;
53 break;
54 }
55 }
56
57 auto *f = ROMFS::find_stream(uri.c_str());
58 if (f != nullptr) {
59 server.sendHeader("Content-Encoding", "gzip");
60 server.streamFile(*f, content_type);
61 delete f;
62 return true;
63 }
64 return false;
65 }
66
67} ROMFS_Handler;
68

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected