master
parent
f27aadd39c
commit
1aed804578
@ -0,0 +1,42 @@
|
||||
#include "http_request.h"
|
||||
#include "controller/mastodon_api.h"
|
||||
|
||||
bool route_asset( struct http_request* req )
|
||||
{
|
||||
static struct allowed_t {
|
||||
const char* route_path;
|
||||
const char* fs_path;
|
||||
const char* mime_type;
|
||||
} allowed[] = {
|
||||
{ "style.css", "src/assets/style.css", "text/css" },
|
||||
{ "jquery.js", "src/assets/jquery.js", "application/javascript" },
|
||||
{ "jquery.plugins.js", "src/assets/jquery.plugins.js", "application/javascript" },
|
||||
{ "background_noise.png","src/assets/background_noise.png", "image/png" },
|
||||
{ "feed-icon-28x28.png", "src/assets/feed-icon-28x28.png", "image/png" },
|
||||
};
|
||||
|
||||
for( int i = 0; i < sizeof(allowed)/sizeof(struct allowed_t); ++i ) {
|
||||
if( http_request_route_term( req, allowed[i].route_path ) ) {
|
||||
return http_request_send_file( req, allowed[i].fs_path, allowed[i].mime_type );
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool route_request( struct http_request* req )
|
||||
{
|
||||
if( http_request_route( req, "/api/v1/" ) ) {
|
||||
return route_mastodon_api( req );
|
||||
}
|
||||
if( http_request_route( req, "/.well-known" ) ) {
|
||||
return false;
|
||||
}
|
||||
if( http_request_route( req, "/assets/" ) ) {
|
||||
printf( "handling asset\n" );
|
||||
return route_asset(req);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
struct http_request;
|
||||
|
||||
bool route_request( struct http_request* req );
|
||||
|
@ -0,0 +1 @@
|
||||
Page not found.
|
Loading…
Reference in new issue