Handler Configuration to Default index.html

Skip to first unread message


Oct 7, 2019, 4:21:37 AM10/7/19
to onion-dev
Hi there

Typically servers can be configured to default an /index.html URL to root ( / ).

I have a Javascript Web application which currently I use the first handler below to respond to a GET with the /index.html suffix, however the URL needs to be, for example, http:/localhost:8000/index.html. Is it possible, without writing a custom handler, to get a GET to default the index.html to a UR http:/localhost:8000/?

Thanks, Bill

    /* HTTP root */
    onion_url *urls = onion_root_url(_http.onion);

    /* HTTP handler for static content (e.g. browser) */    
    onion_handler *pages = onion_handler_export_local_new(properties.SA_HTTP_WEB_ROOT);
    onion_handler_add(onion_url_to_handler(urls), pages);  
    /* HTTP handlers for SSSE, JSON */
    onion_url_add(urls, "json/v1.00", handler_json);
    onion_url_add(urls, "sse/v1.00", handler_sse);

    /* HTTP handler for media image files so we can get image files */
    onion_handler *media = sa_handler_export_local_new(properties.SA_PATH_MEDIA_SOURCES_MOUNTPOINT);
    onion_handler_add(onion_url_to_handler(urls), media);                         
    /* Default handler fall-back */
    onion_url_add_static(urls, "^$", "Server version 1.0\r\n", HTTP_OK);

Reply all
Reply to author
0 new messages