2017-04-12 13:39:03 +00:00
|
|
|
// Code generated by. DO NOT EDIT.
|
|
|
|
/* This file was automatically generated by the software. Please don't edit it as your changes may be overwritten at any moment. */
|
|
|
|
package main
|
|
|
|
|
2017-04-13 09:26:40 +00:00
|
|
|
//import "fmt"
|
2017-04-12 13:39:03 +00:00
|
|
|
import "sync"
|
2017-04-13 09:26:40 +00:00
|
|
|
import "strings"
|
2017-04-12 13:39:03 +00:00
|
|
|
import "net/http"
|
|
|
|
|
|
|
|
type GenRouter struct {
|
|
|
|
UploadHandler func(http.ResponseWriter, *http.Request)
|
|
|
|
sync.RWMutex // Temporary Fallback
|
|
|
|
old_routes map[string]func(http.ResponseWriter, *http.Request) // Temporary Fallback
|
|
|
|
}
|
|
|
|
|
2017-04-13 09:26:40 +00:00
|
|
|
func NewGenRouter(uploads http.Handler) *GenRouter {
|
2017-04-12 13:39:03 +00:00
|
|
|
return &GenRouter{
|
2017-04-13 09:26:40 +00:00
|
|
|
UploadHandler: http.StripPrefix("/uploads/",uploads).ServeHTTP,
|
2017-04-12 13:39:03 +00:00
|
|
|
old_routes: make(map[string]func(http.ResponseWriter, *http.Request)),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-13 09:26:40 +00:00
|
|
|
func (router *GenRouter) Handle(_ string, _ http.Handler) {
|
2017-04-12 13:39:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (router *GenRouter) HandleFunc(pattern string, handle func(http.ResponseWriter, *http.Request)) {
|
|
|
|
router.Lock()
|
|
|
|
router.old_routes[pattern] = handle
|
|
|
|
router.Unlock()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
2017-04-13 09:26:40 +00:00
|
|
|
//if req.URL.Path == "/" {
|
|
|
|
// default_route(w,req)
|
|
|
|
// return
|
|
|
|
//}
|
2017-04-12 13:39:03 +00:00
|
|
|
if req.URL.Path[0] != '/' {
|
|
|
|
w.WriteHeader(405)
|
|
|
|
w.Write([]byte(""))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-04-13 09:26:40 +00:00
|
|
|
var prefix, extra_data string
|
|
|
|
prefix = req.URL.Path[0:strings.IndexByte(req.URL.Path[1:],'/') + 1]
|
|
|
|
if req.URL.Path[len(req.URL.Path) - 1] != '/' {
|
2017-04-12 13:39:03 +00:00
|
|
|
extra_data = req.URL.Path[strings.LastIndexByte(req.URL.Path,'/') + 1:]
|
|
|
|
req.URL.Path = req.URL.Path[:strings.LastIndexByte(req.URL.Path,'/') + 1]
|
2017-04-13 09:26:40 +00:00
|
|
|
}
|
|
|
|
//fmt.Println("prefix:",prefix)
|
|
|
|
//fmt.Println("req.URL.Path:",req.URL.Path)
|
|
|
|
//fmt.Println("extra_data:",extra_data)
|
|
|
|
switch(prefix) {
|
2017-05-02 17:24:33 +00:00
|
|
|
case "/api":
|
|
|
|
route_api(w,req)
|
|
|
|
return
|
2017-04-13 09:26:40 +00:00
|
|
|
case "/static":
|
|
|
|
req.URL.Path += extra_data
|
|
|
|
route_static(w,req)
|
|
|
|
return
|
|
|
|
case "/overview":
|
|
|
|
route_overview(w,req)
|
|
|
|
return
|
|
|
|
case "/forums":
|
|
|
|
route_forums(w,req)
|
|
|
|
return
|
2017-04-13 15:01:30 +00:00
|
|
|
case "/forum":
|
|
|
|
route_forum(w,req,extra_data)
|
|
|
|
return
|
2017-05-02 17:24:33 +00:00
|
|
|
case "/report":
|
|
|
|
switch(req.URL.Path) {
|
|
|
|
case "/report/submit/":
|
|
|
|
route_report_submit(w,req,extra_data)
|
|
|
|
return
|
|
|
|
}
|
2017-04-13 09:26:40 +00:00
|
|
|
case "/topics":
|
|
|
|
switch(req.URL.Path) {
|
|
|
|
case "/topics/create/":
|
2017-04-13 15:01:30 +00:00
|
|
|
route_topic_create(w,req,extra_data)
|
2017-04-13 09:26:40 +00:00
|
|
|
return
|
2017-04-13 10:55:51 +00:00
|
|
|
default:
|
|
|
|
route_topics(w,req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
case "/panel":
|
|
|
|
switch(req.URL.Path) {
|
|
|
|
case "/panel/forums/":
|
|
|
|
route_panel_forums(w,req)
|
|
|
|
return
|
|
|
|
case "/panel/forums/create/":
|
|
|
|
route_panel_forums_create_submit(w,req)
|
|
|
|
return
|
|
|
|
case "/panel/forums/delete/":
|
2017-04-13 15:01:30 +00:00
|
|
|
route_panel_forums_delete(w,req,extra_data)
|
2017-04-13 10:55:51 +00:00
|
|
|
return
|
|
|
|
case "/panel/forums/delete/submit/":
|
2017-04-13 15:01:30 +00:00
|
|
|
route_panel_forums_delete_submit(w,req,extra_data)
|
2017-04-13 10:55:51 +00:00
|
|
|
return
|
|
|
|
case "/panel/forums/edit/":
|
2017-04-13 15:01:30 +00:00
|
|
|
route_panel_forums_edit(w,req,extra_data)
|
2017-04-13 10:55:51 +00:00
|
|
|
return
|
|
|
|
case "/panel/forums/edit/submit/":
|
2017-04-13 15:01:30 +00:00
|
|
|
route_panel_forums_edit_submit(w,req,extra_data)
|
|
|
|
return
|
|
|
|
case "/panel/settings/":
|
|
|
|
route_panel_settings(w,req)
|
|
|
|
return
|
|
|
|
case "/panel/settings/edit/":
|
|
|
|
route_panel_setting(w,req,extra_data)
|
|
|
|
return
|
|
|
|
case "/panel/settings/edit/submit/":
|
|
|
|
route_panel_setting_edit(w,req,extra_data)
|
|
|
|
return
|
|
|
|
case "/panel/themes/":
|
|
|
|
route_panel_themes(w,req)
|
|
|
|
return
|
|
|
|
case "/panel/themes/default/":
|
|
|
|
route_panel_themes_default(w,req,extra_data)
|
|
|
|
return
|
|
|
|
case "/panel/plugins/":
|
|
|
|
route_panel_plugins(w,req)
|
|
|
|
return
|
|
|
|
case "/panel/plugins/activate/":
|
|
|
|
route_panel_plugins_activate(w,req,extra_data)
|
|
|
|
return
|
|
|
|
case "/panel/plugins/deactivate/":
|
|
|
|
route_panel_plugins_deactivate(w,req,extra_data)
|
|
|
|
return
|
|
|
|
case "/panel/users/":
|
|
|
|
route_panel_users(w,req)
|
|
|
|
return
|
|
|
|
case "/panel/users/edit/":
|
|
|
|
route_panel_users_edit(w,req,extra_data)
|
|
|
|
return
|
|
|
|
case "/panel/users/edit/submit/":
|
|
|
|
route_panel_users_edit_submit(w,req,extra_data)
|
|
|
|
return
|
|
|
|
case "/panel/groups/":
|
|
|
|
route_panel_groups(w,req)
|
|
|
|
return
|
|
|
|
case "/panel/groups/edit/":
|
|
|
|
route_panel_groups_edit(w,req,extra_data)
|
|
|
|
return
|
|
|
|
case "/panel/groups/edit/perms/":
|
|
|
|
route_panel_groups_edit_perms(w,req,extra_data)
|
|
|
|
return
|
|
|
|
case "/panel/groups/edit/submit/":
|
|
|
|
route_panel_groups_edit_submit(w,req,extra_data)
|
|
|
|
return
|
|
|
|
case "/panel/groups/edit/perms/submit/":
|
|
|
|
route_panel_groups_edit_perms_submit(w,req,extra_data)
|
|
|
|
return
|
|
|
|
case "/panel/groups/create/":
|
|
|
|
route_panel_groups_create_submit(w,req)
|
|
|
|
return
|
|
|
|
case "/panel/logs/mod/":
|
|
|
|
route_panel_logs_mod(w,req)
|
2017-04-13 10:55:51 +00:00
|
|
|
return
|
|
|
|
default:
|
|
|
|
route_panel(w,req)
|
|
|
|
return
|
2017-04-13 09:26:40 +00:00
|
|
|
}
|
|
|
|
case "/uploads":
|
|
|
|
if extra_data == "" {
|
|
|
|
NotFound(w,req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
req.URL.Path += extra_data
|
|
|
|
router.UploadHandler(w,req)
|
|
|
|
return
|
|
|
|
case "":
|
|
|
|
default_route(w,req)
|
|
|
|
return
|
2017-04-12 13:39:03 +00:00
|
|
|
//default: NotFound(w,req)
|
|
|
|
}
|
|
|
|
|
|
|
|
// A fallback for the routes which haven't been converted to the new router yet
|
|
|
|
router.RLock()
|
|
|
|
handle, ok := router.old_routes[req.URL.Path]
|
2017-04-13 09:26:40 +00:00
|
|
|
router.RUnlock()
|
|
|
|
|
2017-04-12 13:39:03 +00:00
|
|
|
if ok {
|
2017-04-13 09:26:40 +00:00
|
|
|
req.URL.Path += extra_data
|
2017-04-12 13:39:03 +00:00
|
|
|
handle(w,req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
NotFound(w,req)
|
|
|
|
}
|