Always send index for spa, move org to api

This commit is contained in:
Florian Schroedl
2022-05-30 20:57:45 +02:00
parent da2b4dc903
commit e4f4b76afe

View File

@@ -96,11 +96,13 @@ proc sendOrgFile(env: Env, id: orgId, path: seq[string]): NimHttpResponse =
) )
) )
proc sendIndex(env: Env): auto =
sendStaticFile(env, path = @["index.html"])
proc handleRoute(env: Env, req: Request): NimHttpResponse = proc handleRoute(env: Env, req: Request): NimHttpResponse =
# Handle main route # Handle main route
if req.url.path == "/": if req.url.path == "/":
return sendStaticFile(env, path = @["index.html"]) return sendIndex(env)
var path = req.url.path.split("/") var path = req.url.path.split("/")
path.delete(0) path.delete(0)
@@ -110,10 +112,10 @@ proc handleRoute(env: Env, req: Request): NimHttpResponse =
case (req.reqMethod, path): case (req.reqMethod, path):
of (HttpGet, ["dist", .._]): of (HttpGet, ["dist", .._]):
sendStaticFile(env, path) sendStaticFile(env, path)
of (HttpGet, ["org", @id, all @rest]): of (HttpGet, ["api", "org", @id, all @rest]):
sendOrgFile(env, id, rest) sendOrgFile(env, id, rest)
else: else:
sendNotFound(env, path) sendIndex(env)
) )