annotate env/request/router.lua @ 1650:12a73990db76
Added icons to context links in issue listing
 | author | 
 bsw | 
 | date | 
 Fri Feb 12 17:26:00 2021 +0100 (2021-02-12) | 
 | parents | 
 bbb537ba81b2  | 
 | children | 
 09f275c1f606  | 
 
 | rev | 
   line source | 
| 
bsw/jbe@1309
 | 
     1 local api_endpoints = {
 | 
| 
bsw/jbe@1309
 | 
     2   instance = true,
 | 
| 
bsw/jbe@1309
 | 
     3   navigation = true,
 | 
| 
bsw/jbe@1309
 | 
     4   style = true,
 | 
| 
bsw/jbe@1309
 | 
     5   application = true,
 | 
| 
bsw/jbe@1309
 | 
     6   info = true,
 | 
| 
bsw/jbe@1309
 | 
     7   member = true,
 | 
| 
bsw@1635
 | 
     8   avatar = true,
 | 
| 
bsw/jbe@1309
 | 
     9   notify_email = true,
 | 
| 
bsw/jbe@1309
 | 
    10   profile_info = true,
 | 
| 
bsw/jbe@1309
 | 
    11   profile = true,
 | 
| 
bsw/jbe@1309
 | 
    12   settings_info = true,
 | 
| 
bsw/jbe@1309
 | 
    13   settings = true,
 | 
| 
bsw@1498
 | 
    14   event = true,
 | 
| 
bsw@1500
 | 
    15   support = true,
 | 
| 
bsw@1526
 | 
    16   embed_initiative = true,
 | 
| 
bsw@1526
 | 
    17   login = true
 | 
| 
bsw/jbe@1309
 | 
    18 }
 | 
| 
bsw/jbe@1309
 | 
    19 
 | 
| 
bsw/jbe@1309
 | 
    20 function request.router()
 | 
| 
bsw/jbe@1309
 | 
    21   
 | 
| 
bsw/jbe@1309
 | 
    22   local api_prefix = "api/1/"
 | 
| 
bsw/jbe@1309
 | 
    23   
 | 
| 
bsw/jbe@1309
 | 
    24   local path = request.get_path()
 | 
| 
bsw/jbe@1309
 | 
    25   
 | 
| 
bsw/jbe@1309
 | 
    26   if path == api_prefix .. "register" then
 | 
| 
bsw/jbe@1309
 | 
    27     return { module = "oauth2", view = "register" }
 | 
| 
bsw/jbe@1309
 | 
    28   elseif path == api_prefix .. "authorization" then
 | 
| 
bsw/jbe@1309
 | 
    29     return { module = "oauth2", view = "authorization" }
 | 
| 
bsw/jbe@1309
 | 
    30   elseif path == api_prefix .. "token" then
 | 
| 
bsw/jbe@1309
 | 
    31     return { module = "oauth2", view = "token" }
 | 
| 
bsw/jbe@1309
 | 
    32   elseif path == api_prefix .. "validate" then
 | 
| 
bsw/jbe@1309
 | 
    33     return { module = "oauth2", view = "validate" }
 | 
| 
bsw/jbe@1309
 | 
    34   elseif path == api_prefix .. "session" then
 | 
| 
bsw/jbe@1309
 | 
    35     return { module = "oauth2", view = "session" }
 | 
| 
bsw/jbe@1309
 | 
    36   else
 | 
| 
bsw/jbe@1309
 | 
    37     local endpoint = string.match(path, "^" .. api_prefix .. "(.*)$")
 | 
| 
bsw/jbe@1309
 | 
    38     if api_endpoints[endpoint] then
 | 
| 
bsw/jbe@1309
 | 
    39       return { module = "api", view = endpoint }
 | 
| 
bsw/jbe@1309
 | 
    40     end
 | 
| 
bsw/jbe@1309
 | 
    41   end
 | 
| 
bsw/jbe@1309
 | 
    42   
 | 
| 
bsw/jbe@1309
 | 
    43   return request.default_router(path)
 | 
| 
bsw/jbe@1309
 | 
    44   
 | 
| 
bsw/jbe@1309
 | 
    45 end
 |