tbs
This commit is contained in:
@@ -28,6 +28,15 @@ func Authenticate(service service.Auth) func(http.Handler) http.Handler {
|
||||
}
|
||||
}
|
||||
|
||||
func GetSession(r *http.Request) *service.Session {
|
||||
obj := r.Context().Value(SessionKey)
|
||||
if obj == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return obj.(*service.Session)
|
||||
}
|
||||
|
||||
func getSessionID(r *http.Request) string {
|
||||
cookie, err := r.Cookie("id")
|
||||
if err != nil {
|
||||
|
||||
1
main.go
1
main.go
@@ -81,6 +81,7 @@ func startServer(s *http.Server) {
|
||||
log.Info("Starting server on %v", s.Addr)
|
||||
if err := s.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
||||
log.Error("error listening and serving: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"me-fit/db"
|
||||
"me-fit/log"
|
||||
"me-fit/service"
|
||||
"me-fit/types"
|
||||
@@ -91,11 +90,6 @@ func setupIntegrationTest(t *testing.T, port string) (*sql.DB, context.Context)
|
||||
database.Close()
|
||||
})
|
||||
|
||||
err = db.RunMigrations(database, "")
|
||||
if err != nil {
|
||||
t.Fatalf("Could not run migrations: %v", err)
|
||||
}
|
||||
|
||||
go run(ctx, database, getEnv(port))
|
||||
|
||||
err = waitForReady(ctx, 5*time.Second, "http://localhost:8080")
|
||||
|
||||
Reference in New Issue
Block a user