// 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 //import "fmt" import "sync" import "strings" 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 } func NewGenRouter(uploads http.Handler) *GenRouter { return &GenRouter{ UploadHandler: http.StripPrefix("/uploads/",uploads).ServeHTTP, old_routes: make(map[string]func(http.ResponseWriter, *http.Request)), } } func (router *GenRouter) Handle(_ string, _ http.Handler) { } 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) { //if req.URL.Path == "/" { // default_route(w,req) // return //} if req.URL.Path[0] != '/' { w.WriteHeader(405) w.Write([]byte("")) return } 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] != '/' { extra_data = req.URL.Path[strings.LastIndexByte(req.URL.Path,'/') + 1:] req.URL.Path = req.URL.Path[:strings.LastIndexByte(req.URL.Path,'/') + 1] } //fmt.Println("prefix:",prefix) //fmt.Println("req.URL.Path:",req.URL.Path) //fmt.Println("extra_data:",extra_data) switch(prefix) { case "/static": req.URL.Path += extra_data route_static(w,req) return case "/overview": route_overview(w,req) return case "/pages": route_custom_page(w,req) return case "/forums": route_forums(w,req) return case "/topics": switch(req.URL.Path) { case "/topics/": route_topics(w,req) return case "/topics/create/": route_topic_create(w,req, extra_data) return } 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 //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] router.RUnlock() if ok { req.URL.Path += extra_data handle(w,req) return } NotFound(w,req) }