set restriction, fix print
This commit is contained in:
parent
80ccd7101d
commit
433a19a2db
@ -2,7 +2,6 @@ package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"log"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
@ -49,14 +48,15 @@ func New(logger *log.Logger, config *ServiceConfig) *Service {
|
||||
func (s *Service) SetupRoutes() {
|
||||
s.Gin.Use(gin.Logger())
|
||||
s.Gin.Use(s.Recovery)
|
||||
s.Gin.Use(s.RequireBody)
|
||||
|
||||
ac := s.Gin.Group("/account")
|
||||
ac.POST("/signup", s.Signup)
|
||||
ac.POST("/login", s.Login)
|
||||
ac.POST("/logout", s.Logout)
|
||||
ac.GET("/logout", s.RequireSession, s.Logout)
|
||||
|
||||
s.Gin.NoRoute(func(c *gin.Context) {
|
||||
s.Error(c, http.StatusNotFound, errors.New("this route doesn't exists"))
|
||||
s.Error(c, http.StatusNotFound, ErrReqNotFound)
|
||||
})
|
||||
|
||||
}
|
||||
@ -84,7 +84,7 @@ func (s *Service) Run() error {
|
||||
// a timeout of 5 seconds.
|
||||
signal.Notify(quit, os.Interrupt)
|
||||
<-quit
|
||||
s.Logger.Println("shutdown ...")
|
||||
s.Logger.Print("shutdown ...")
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
@ -96,11 +96,11 @@ func (s *Service) Run() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.Logger.Println("closing database ...")
|
||||
s.Logger.Print("closing database ...")
|
||||
if err := db.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
s.Logger.Println("exiting")
|
||||
s.Logger.Print("exiting")
|
||||
return runError
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user