mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 16:59:12 +00:00
Feature: Set and display version info (#63)
* chore: update packages * feat: show version info * build: remove ldflags override
This commit is contained in:
parent
c65c7477fd
commit
b09796bf7e
9 changed files with 50 additions and 15 deletions
|
@ -14,14 +14,22 @@ type configJson struct {
|
|||
LogLevel string `json:"log_level"`
|
||||
LogPath string `json:"log_path"`
|
||||
BaseURL string `json:"base_url"`
|
||||
Version string `json:"version"`
|
||||
Commit string `json:"commit"`
|
||||
Date string `json:"date"`
|
||||
}
|
||||
|
||||
type configHandler struct {
|
||||
encoder encoder
|
||||
|
||||
server Server
|
||||
}
|
||||
|
||||
func newConfigHandler(encoder encoder) *configHandler {
|
||||
return &configHandler{encoder: encoder}
|
||||
func newConfigHandler(encoder encoder, server Server) *configHandler {
|
||||
return &configHandler{
|
||||
encoder: encoder,
|
||||
server: server,
|
||||
}
|
||||
}
|
||||
|
||||
func (h configHandler) Routes(r chi.Router) {
|
||||
|
@ -39,6 +47,9 @@ func (h configHandler) getConfig(w http.ResponseWriter, r *http.Request) {
|
|||
LogLevel: c.LogLevel,
|
||||
LogPath: c.LogPath,
|
||||
BaseURL: c.BaseURL,
|
||||
Version: h.server.version,
|
||||
Commit: h.server.commit,
|
||||
Date: h.server.date,
|
||||
}
|
||||
|
||||
h.encoder.StatusResponse(ctx, w, conf, http.StatusOK)
|
||||
|
|
|
@ -19,6 +19,10 @@ type Server struct {
|
|||
address string
|
||||
baseUrl string
|
||||
|
||||
version string
|
||||
commit string
|
||||
date string
|
||||
|
||||
actionService actionService
|
||||
authService authService
|
||||
downloadClientService downloadClientService
|
||||
|
@ -28,11 +32,14 @@ type Server struct {
|
|||
releaseService releaseService
|
||||
}
|
||||
|
||||
func NewServer(sse *sse.Server, address string, baseUrl string, actionService actionService, authService authService, downloadClientSvc downloadClientService, filterSvc filterService, indexerSvc indexerService, ircSvc ircService, releaseSvc releaseService) Server {
|
||||
func NewServer(sse *sse.Server, address string, baseUrl string, version string, commit string, date string, actionService actionService, authService authService, downloadClientSvc downloadClientService, filterSvc filterService, indexerSvc indexerService, ircSvc ircService, releaseSvc releaseService) Server {
|
||||
return Server{
|
||||
sse: sse,
|
||||
address: address,
|
||||
baseUrl: baseUrl,
|
||||
version: version,
|
||||
commit: commit,
|
||||
date: date,
|
||||
|
||||
actionService: actionService,
|
||||
authService: authService,
|
||||
|
@ -91,7 +98,7 @@ func (s Server) Handler() http.Handler {
|
|||
|
||||
r.Route("/api", func(r chi.Router) {
|
||||
r.Route("/actions", newActionHandler(encoder, s.actionService).Routes)
|
||||
r.Route("/config", newConfigHandler(encoder).Routes)
|
||||
r.Route("/config", newConfigHandler(encoder, s).Routes)
|
||||
r.Route("/download_clients", newDownloadClientHandler(encoder, s.downloadClientService).Routes)
|
||||
r.Route("/filters", newFilterHandler(encoder, s.filterService).Routes)
|
||||
r.Route("/irc", newIrcHandler(encoder, s.ircService).Routes)
|
||||
|
|
|
@ -50,7 +50,4 @@ func Setup(cfg domain.Config, sse *sse.Server) {
|
|||
|
||||
log.Logger = log.Hook(&ServerSentEventHook{sse: sse})
|
||||
log.Logger = log.Output(writers)
|
||||
|
||||
log.Print("Starting autobrr")
|
||||
log.Printf("Log-level: %v", cfg.LogLevel)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue