mdidle ware set
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
)
|
||||
|
||||
func Register() {
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gorm"
|
||||
@@ -53,7 +54,16 @@ func InitDBconnection() {
|
||||
func InitChiRouting() {
|
||||
slog.Info("Init routing")
|
||||
r := chi.NewRouter()
|
||||
|
||||
// middlewares
|
||||
r.Use(middleware.Logger)
|
||||
r.Use(middleware.Timeout(60 * time.Second))
|
||||
r.Use(middleware.RequestID)
|
||||
r.Use(middleware.CleanPath)
|
||||
r.Use(middleware.Heartbeat("/ping"))
|
||||
r.Use(middleware.NoCache)
|
||||
r.Use(middleware.Recoverer)
|
||||
|
||||
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("welcome developer! Cool."))
|
||||
})
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/golang-jwt/jwt/v4"
|
||||
)
|
||||
|
||||
var jwtKey = []byte(os.Getenv("SECRET_KEY"))
|
||||
|
||||
type Crenetials struct {
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
type Claims struct {
|
||||
jwt.RegisteredClaims
|
||||
Email string `json:"email"`
|
||||
}
|
||||
@@ -8,4 +8,4 @@ type User struct {
|
||||
Email string `json:"email" gorm:"type:string;index"`
|
||||
Password string `json:"password" gorm:"type:string;index"`
|
||||
Phone string `json:"phone" gorm:"type:string;index"`
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user