MCPcopy Create free account
hub / github.com/SmingHub/Sming / onFile

Function onFile

samples/HttpServer_WebSockets/app/application.cpp:31–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31void onFile(HttpRequest& request, HttpResponse& response)
32{
33 String file = request.uri.getRelativePath();
34
35 if(file[0] == '.') {
36 response.code = HTTP_STATUS_FORBIDDEN;
37 } else {
38 response.setCache(86400, true); // It's important to use cache for better performance.
39 response.sendFile(file);
40 }
41}
42
43void shutdownServer()
44{

Callers

nothing calls this directly

Calls 3

getRelativePathMethod · 0.80
setCacheMethod · 0.80
sendFileMethod · 0.45

Tested by

no test coverage detected