123456789101112131415161718192021222324252627282930313233343536 |
- package main
- import (
- "log"
- "net/http"
- "github.com/andreanidouglas/auth/model"
- "github.com/andreanidouglas/auth/routes"
- "golang.org/x/crypto/bcrypt"
- )
- func health_check(w http.ResponseWriter, r *http.Request) {
- w.WriteHeader(200)
- }
- func main () {
- db := model.NewDb("./auth.db")
- db.Setup()
- passwd, err := bcrypt.GenerateFromPassword([]byte("d5022a"), 5)
- if err != nil {
- log.Fatalf("Could not create password: %v", err)
- }
- u := model.User{Email: "cmtedouglas@hotmail.com", Password: string(passwd), Name: "Douglas", ID: 1}
- model.CreateUser(&u, &db)
- routes.Init()
-
- http.HandleFunc("/auth/login", routes.Login)
- http.HandleFunc("/api/users", routes.AuthMiddleware(health_check))
- http.ListenAndServe(":8080", nil)
- }
|