mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
feat(http): add healthcheck endpoints liveness and readiness (#240)
* feat(http): add liveness and readiness endpoints * feat(http): improve unhealthy msg
This commit is contained in:
parent
4b74a006c8
commit
2a3b5ce448
4 changed files with 61 additions and 2 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"net"
|
||||
"net/http"
|
||||
|
||||
"github.com/autobrr/autobrr/internal/database"
|
||||
"github.com/autobrr/autobrr/internal/domain"
|
||||
"github.com/autobrr/autobrr/web"
|
||||
|
||||
|
@ -17,6 +18,7 @@ import (
|
|||
|
||||
type Server struct {
|
||||
sse *sse.Server
|
||||
db *database.DB
|
||||
|
||||
config domain.Config
|
||||
cookieStore *sessions.CookieStore
|
||||
|
@ -35,10 +37,11 @@ type Server struct {
|
|||
releaseService releaseService
|
||||
}
|
||||
|
||||
func NewServer(config domain.Config, sse *sse.Server, version string, commit string, date string, actionService actionService, authService authService, downloadClientSvc downloadClientService, filterSvc filterService, indexerSvc indexerService, ircSvc ircService, notificationSvc notificationService, releaseSvc releaseService) Server {
|
||||
func NewServer(config domain.Config, sse *sse.Server, db *database.DB, version string, commit string, date string, actionService actionService, authService authService, downloadClientSvc downloadClientService, filterSvc filterService, indexerSvc indexerService, ircSvc ircService, notificationSvc notificationService, releaseSvc releaseService) Server {
|
||||
return Server{
|
||||
config: config,
|
||||
sse: sse,
|
||||
db: db,
|
||||
version: version,
|
||||
commit: commit,
|
||||
date: date,
|
||||
|
@ -98,6 +101,7 @@ func (s Server) Handler() http.Handler {
|
|||
})
|
||||
|
||||
r.Route("/api/auth", newAuthHandler(encoder, s.config, s.cookieStore, s.authService).Routes)
|
||||
r.Route("/api/healthz", newHealthHandler(encoder, s.db).Routes)
|
||||
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Use(s.IsAuthenticated)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue