Set session limit and add secret to server struct.
This commit is contained in:
+10
-5
@@ -7,17 +7,23 @@ import (
|
||||
"nfeeder/internal/db"
|
||||
)
|
||||
|
||||
var MAX_USER_SESSIONS = 5
|
||||
|
||||
type Server struct {
|
||||
httpServer *http.Server
|
||||
store *db.Store
|
||||
store *db.Store
|
||||
jwtSecret []byte
|
||||
}
|
||||
|
||||
func NewServer(store *db.Store) *Server {
|
||||
s := &Server {
|
||||
func NewServer(store *db.Store, secret string) *Server {
|
||||
s := &Server{
|
||||
store: store,
|
||||
// could extend this to something more generic
|
||||
// will do if more fields needed
|
||||
jwtSecret: []byte(secret),
|
||||
}
|
||||
|
||||
s.httpServer = &http.Server {
|
||||
s.httpServer = &http.Server{
|
||||
Handler: s.setupRoutes(),
|
||||
}
|
||||
|
||||
@@ -32,4 +38,3 @@ func (s *Server) Start(addr string) error {
|
||||
func (s *Server) Shutdown(ctx context.Context) error {
|
||||
return s.httpServer.Shutdown(ctx)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user