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 =
# Handle main route
if req.url.path == "/":
return sendStaticFile(env, path = @["index.html"])
return sendIndex(env)
var path = req.url.path.split("/")
path.delete(0)
@@ -110,10 +112,10 @@ proc handleRoute(env: Env, req: Request): NimHttpResponse =
case (req.reqMethod, path):
of (HttpGet, ["dist", .._]):
sendStaticFile(env, path)
of (HttpGet, ["org", @id, all @rest]):
of (HttpGet, ["api", "org", @id, all @rest]):
sendOrgFile(env, id, rest)
else:
sendNotFound(env, path)
sendIndex(env)
)