robots.txt => C

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4832 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2024-02-08 01:08:05 +00:00
parent 0de932bc9e
commit e87acc6286
3 changed files with 15 additions and 6 deletions

View File

@ -38,7 +38,6 @@ let k_static_files = [
{uri: '/client.js', type: 'text/javascript; charset=UTF-8'},
{uri: '/favicon.png', type: 'image/png'},
{uri: '/jszip.min.js', type: 'text/javascript; charset=UTF-8'},
{uri: '/robots.txt', type: 'text/plain; charset=UTF-8'},
{uri: '/style.css', type: 'text/css; charset=UTF-8'},
{uri: '/tfrpc.js', type: 'text/javascript; charset=UTF-8', headers: {'Access-Control-Allow-Origin': 'null'}},
{uri: '/w3.css', type: 'text/css; charset=UTF-8'},
@ -1013,8 +1012,6 @@ loadSettings().then(function() {
return staticDirectoryHandler(request, response, 'deps/speedscope/', match[1]);
} else if (match = /^\/static(\/.*)/.exec(request.uri)) {
return staticFileHandler(request, response, null, match[1]);
} else if (request.uri == "/robots.txt") {
return staticFileHandler(request, response, null, request.uri);
} else if (match = /^(.*)(\/(?:save|delete)?)$/.exec(request.uri)) {
return blobHandler(request, response, match[1], match[2]);
} else if ((match = /^\/.well-known\/(.*)/.exec(request.uri)) && request.uri.indexOf("..") == -1) {

View File

@ -1,3 +0,0 @@
User-Agent: *
Disallow: /*/*/edit
Allow: /

View File

@ -508,6 +508,20 @@ static void _httpd_endpoint_hitches(tf_http_request_t* request)
tf_free(response);
}
static void _httpd_endpoint_robots_txt(tf_http_request_t* request)
{
if (_httpd_redirect(request))
{
return;
}
char* response =
"User-Agent: *\n"
"Disallow: /*/*/edit\n"
"Allow: /\n";
const char* headers[] = { "Content-Type", "text/plain; charset=utf-8" };
tf_http_respond(request, 200, headers, tf_countof(headers) / 2, response, response ? strlen(response) : 0);
}
static void _httpd_endpoint_debug(tf_http_request_t* request)
{
if (_httpd_redirect(request))
@ -557,6 +571,7 @@ void tf_httpd_register(JSContext* context)
tf_http_set_trace(http, tf_task_get_trace(task));
JS_SetOpaque(httpd, http);
tf_http_add_handler(http, "/robots.txt", _httpd_endpoint_robots_txt, NULL, NULL);
tf_http_add_handler(http, "/debug", _httpd_endpoint_debug, NULL, task);
tf_http_add_handler(http, "/disconnections", _httpd_endpoint_disconnections, NULL, task);
tf_http_add_handler(http, "/hitches", _httpd_endpoint_hitches, NULL, task);