mirror of
				https://github.com/nkanaev/yarr.git
				synced 2025-10-30 06:31:07 +00:00 
			
		
		
		
	refactoring
This commit is contained in:
		| @@ -9,7 +9,7 @@ import ( | |||||||
| 	"mime" | 	"mime" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| func Index(rw http.ResponseWriter, req *http.Request) { | func IndexHandler(rw http.ResponseWriter, req *http.Request) { | ||||||
| 	fmt.Println(os.Getwd()) | 	fmt.Println(os.Getwd()) | ||||||
| 	f, err := os.Open("template/index.html") | 	f, err := os.Open("template/index.html") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| @@ -22,7 +22,7 @@ func Index(rw http.ResponseWriter, req *http.Request) { | |||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| func Static(rw http.ResponseWriter, req *http.Request) { | func StaticHandler(rw http.ResponseWriter, req *http.Request) { | ||||||
| 	path := "template/static/" + Vars(req)["path"] | 	path := "template/static/" + Vars(req)["path"] | ||||||
| 	f, err := os.Open(path) | 	f, err := os.Open(path) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| @@ -34,14 +34,14 @@ func Static(rw http.ResponseWriter, req *http.Request) { | |||||||
| 	io.Copy(rw, f) | 	io.Copy(rw, f) | ||||||
| } | } | ||||||
|  |  | ||||||
| func FolderList(rw http.ResponseWriter, req *http.Request) { | func FolderListHandler(rw http.ResponseWriter, req *http.Request) { | ||||||
| } | } | ||||||
|  |  | ||||||
| func Folder(rw http.ResponseWriter, req *http.Request) { | func FolderHandler(rw http.ResponseWriter, req *http.Request) { | ||||||
| } | } | ||||||
|  |  | ||||||
| func FeedList(rw http.ResponseWriter, req *http.Request) { | func FeedListHandler(rw http.ResponseWriter, req *http.Request) { | ||||||
| } | } | ||||||
|  |  | ||||||
| func Feed(rw http.ResponseWriter, req *http.Request) { | func FeedHandler(rw http.ResponseWriter, req *http.Request) { | ||||||
| } | } | ||||||
|   | |||||||
| @@ -32,12 +32,12 @@ func p(path string, handler func(http.ResponseWriter, *http.Request)) Route { | |||||||
| } | } | ||||||
|  |  | ||||||
| var routes []Route = []Route{ | var routes []Route = []Route{ | ||||||
| 	p("/", Index), | 	p("/", IndexHandler), | ||||||
| 	p("/static/*path", Static), | 	p("/static/*path", StaticHandler), | ||||||
| 	p("/api/folders", FolderList), | 	p("/api/folders", FolderListHandler), | ||||||
| 	p("/api/folders/:id", Folder), | 	p("/api/folders/:id", FolderHandler), | ||||||
| 	p("/api/feeds", FeedList), | 	p("/api/feeds", FeedListHandler), | ||||||
| 	p("/api/feeds/:id", Feed), | 	p("/api/feeds/:id", FeedHandler), | ||||||
| } | } | ||||||
|  |  | ||||||
| func Vars(req *http.Request) map[string]string { | func Vars(req *http.Request) map[string]string { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user