Always send index for spa, move org to api
This commit is contained in:
@@ -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)
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user