You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1022 B
C

#include "webfinger.h"
// Submodules
#include "http/server/request.h"
// Standard Library
#include <string.h>
#include <stdlib.h>
bool route_wellknown_webfinger( struct http_request* req )
{
// /.well-known/webfinger?resource=acct:teknomunk@apogee.polaris-1.work
const char* key;
char* resource;
char* resource_orig;
while(( key = http_request_route_query_key( req ) )) {
if( 0 == strcmp(key,"resource") ) {
resource_orig = resource = strdup(http_request_route_query_value(req) );
} else {
http_request_route_query_value(req);
}
}
char* server;
strtok_r( resource, ":", &resource );
/*char* account_name = */strtok_r( resource, "@", &server );
// Verify the server name matches this instance
// if( 0 != strcmp( server, this_server_hostname() ) ) { return false; }
http_request_send_headers( req, 200, "application/json", true );
FILE* f = http_request_get_response_body(req);
#define RENDER
#include "src/view/webfinger.json.inc"
#undef RENDER
free(resource_orig);
return true;
}