g wan - Index as servlet, rest as static content -


i picked g-wan while , i'm trying figure out how make index use specific servlet while having static content available.

i moved index.html index_old.html wouldn't have conflicts.

i placed following handler.

xbuf_t *read_xbuf = (xbuf_t*)get_env(argv, read_xbuf); xbuf_replfrto(read_xbuf, read_xbuf->ptr, read_xbuf->ptr + 16, "/", "/?hello"); 

after restarting gwan, saw hello, ansi c! desired.

however, noticed other contents no longer loaded, 404 page different!

so, had thought, seemed doing string substitution, rather precise matching.

xbuf_t *read_xbuf = (xbuf_t*)get_env(argv, read_xbuf); xbuf_replfrto(read_xbuf, read_xbuf->ptr, read_xbuf->ptr + 16, "/", "/?"); 

now, when hitting /, saw 404, , /hello, saw servlet again. so, not seem solution looking for.

again, want / hit specific servlet of designation, , other requests not effected 1 rule.

thanks,

it appears similar solution presented in g-wan handler rewriting solution

using that, derived following code allows not index generated, additional query strings.

char *szrequest = (char*)get_env(argv, request); if(strncmp(szrequest, "get / ", 6) == 0){         xbuf_t *read_xbuf = (xbuf_t*)get_env(argv, read_xbuf);         xbuf_replfrto(read_xbuf, read_xbuf->ptr, read_xbuf->ptr + 16, "/", "/!hello"); }else if(strncmp(szrequest, "get /?", 6) == 0){         xbuf_t *read_xbuf = (xbuf_t*)get_env(argv, read_xbuf);         xbuf_replfrto(read_xbuf, read_xbuf->ptr, read_xbuf->ptr + 16, "/?", "/!hello&"); } 

as seen above, had move ! avoid conflict. means had add following in init() function.

u8 *query_char = (u8*)get_env(argv, query_char); *query_char = '!';  

i able access / , /?blah without issue, while still being able access file 100.html without getting servlet 404.

it seems other similar bindings url while not blocking off rest of directory can made easier macro.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -