projecto completo creo, me quedo bonito :3

This commit is contained in:
Daniel Cortés
2019-04-17 12:36:31 -04:00
commit 3c55ad2713
17 changed files with 1356 additions and 0 deletions

36
main.go Normal file
View File

@@ -0,0 +1,36 @@
package main
import (
"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
_ "github.com/mattn/go-sqlite3"
"log"
"net/http"
"os"
"path/filepath"
)
func main() {
log.Println("Launching TODO App")
log.Println("Generating the routes...")
workDir, _ := os.Getwd()
filesDir := filepath.Join(workDir, "static")
router := chi.NewRouter()
router.Use(middleware.Logger)
router.Get("/", indexHandler)
router.Get("/edit/{id:[0-9]+}", editHandler)
router.Post("/create", createHandler)
router.Post("/toggle/{id:[0-9]+}", toggleHandler)
router.Post("/update/{id:[0-9]+}", updateHandler)
router.Post("/delete/{id:[0-9]+}", deleteHandler)
fileServer(router, "/static", http.Dir(filesDir))
log.Println("Serving the page on port 1337")
http.ListenAndServe(":1337", router)
}