TaskFlow/main.go

44 lines
2.0 KiB
Go
Raw Normal View History

2015-11-13 17:04:42 +08:00
package main
/**
* This is the main file for the Task application
* License: MIT
**/
import (
"log"
"net/http"
2016-02-01 21:45:04 +08:00
"github.com/thewhitetulip/Tasks/config"
"github.com/thewhitetulip/Tasks/views"
2015-11-13 17:04:42 +08:00
)
func main() {
2016-01-23 18:33:10 +08:00
values := config.ReadConfig("config.json")
2015-11-21 15:58:23 +08:00
views.PopulateTemplates()
2016-05-12 01:19:32 +08:00
http.HandleFunc("/", views.RequiresLogin(views.ShowAllTasksFunc))
2016-05-09 10:11:05 +08:00
http.HandleFunc("/login/", views.LoginFunc)
2016-05-12 01:19:32 +08:00
http.HandleFunc("/logout/", views.RequiresLogin(views.LogoutFunc))
http.HandleFunc("/add-category/", views.RequiresLogin(views.AddCategoryFunc))
http.HandleFunc("/add-comment/", views.RequiresLogin(views.AddCommentFunc))
http.HandleFunc("/del-comment/", views.RequiresLogin(views.DeleteCommentFunc))
http.HandleFunc("/del-category/", views.RequiresLogin(views.DeleteCategoryFunc))
http.HandleFunc("/upd-category/", views.RequiresLogin(views.UpdateCategoryFunc))
http.HandleFunc("/category/", views.RequiresLogin(views.ShowCategoryFunc))
http.HandleFunc("/complete/", views.RequiresLogin(views.CompleteTaskFunc))
http.HandleFunc("/delete/", views.RequiresLogin(views.DeleteTaskFunc))
http.HandleFunc("/files/", views.RequiresLogin(views.UploadedFileHandler))
http.HandleFunc("/deleted/", views.RequiresLogin(views.ShowTrashTaskFunc))
http.HandleFunc("/trash/", views.RequiresLogin(views.TrashTaskFunc))
http.HandleFunc("/edit/", views.RequiresLogin(views.EditTaskFunc))
http.HandleFunc("/completed/", views.RequiresLogin(views.ShowCompleteTasksFunc))
http.HandleFunc("/restore/", views.RequiresLogin(views.RestoreTaskFunc))
http.HandleFunc("/incomplete/", views.RequiresLogin(views.RestoreFromCompleteFunc))
http.HandleFunc("/add/", views.RequiresLogin(views.AddTaskFunc))
http.HandleFunc("/update/", views.RequiresLogin(views.UpdateTaskFunc))
http.HandleFunc("/search/", views.RequiresLogin(views.SearchTaskFunc))
2015-11-21 14:39:06 +08:00
//http.HandleFunc("/static/", ServeStaticFunc)
http.Handle("/static/", http.FileServer(http.Dir("public")))
2016-01-23 18:33:10 +08:00
log.Println("running server on ", values.ServerPort)
log.Fatal(http.ListenAndServe(values.ServerPort, nil))
2015-11-13 17:04:42 +08:00
}