liquid_feedback_frontend
diff env/request/router.lua @ 1309:32cc544d5a5b
Cumulative patch for upcoming frontend version 4
author | bsw/jbe |
---|---|
date | Sun Jul 15 14:07:29 2018 +0200 (2018-07-15) |
parents | |
children | 50f5b8a97f91 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/env/request/router.lua Sun Jul 15 14:07:29 2018 +0200 1.3 @@ -0,0 +1,41 @@ 1.4 +local api_endpoints = { 1.5 + instance = true, 1.6 + navigation = true, 1.7 + style = true, 1.8 + application = true, 1.9 + info = true, 1.10 + member = true, 1.11 + notify_email = true, 1.12 + profile_info = true, 1.13 + profile = true, 1.14 + settings_info = true, 1.15 + settings = true, 1.16 + event = true 1.17 +} 1.18 + 1.19 +function request.router() 1.20 + 1.21 + local api_prefix = "api/1/" 1.22 + 1.23 + local path = request.get_path() 1.24 + 1.25 + if path == api_prefix .. "register" then 1.26 + return { module = "oauth2", view = "register" } 1.27 + elseif path == api_prefix .. "authorization" then 1.28 + return { module = "oauth2", view = "authorization" } 1.29 + elseif path == api_prefix .. "token" then 1.30 + return { module = "oauth2", view = "token" } 1.31 + elseif path == api_prefix .. "validate" then 1.32 + return { module = "oauth2", view = "validate" } 1.33 + elseif path == api_prefix .. "session" then 1.34 + return { module = "oauth2", view = "session" } 1.35 + else 1.36 + local endpoint = string.match(path, "^" .. api_prefix .. "(.*)$") 1.37 + if api_endpoints[endpoint] then 1.38 + return { module = "api", view = endpoint } 1.39 + end 1.40 + end 1.41 + 1.42 + return request.default_router(path) 1.43 + 1.44 +end