mirror of
https://github.com/idanoo/autobrr
synced 2025-07-22 16:29:12 +00:00
feat: add backend
This commit is contained in:
parent
bc418ff248
commit
a838d994a6
68 changed files with 9561 additions and 0 deletions
41
internal/http/config.go
Normal file
41
internal/http/config.go
Normal file
|
@ -0,0 +1,41 @@
|
|||
package http
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/autobrr/autobrr/internal/config"
|
||||
|
||||
"github.com/go-chi/chi"
|
||||
)
|
||||
|
||||
type configJson struct {
|
||||
Host string `json:"host"`
|
||||
Port int `json:"port"`
|
||||
LogLevel string `json:"log_level"`
|
||||
LogPath string `json:"log_path"`
|
||||
BaseURL string `json:"base_url"`
|
||||
}
|
||||
|
||||
type configHandler struct {
|
||||
encoder encoder
|
||||
}
|
||||
|
||||
func (h configHandler) Routes(r chi.Router) {
|
||||
r.Get("/", h.getConfig)
|
||||
}
|
||||
|
||||
func (h configHandler) getConfig(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
c := config.Config
|
||||
|
||||
conf := configJson{
|
||||
Host: c.Host,
|
||||
Port: c.Port,
|
||||
LogLevel: c.LogLevel,
|
||||
LogPath: c.LogPath,
|
||||
BaseURL: c.BaseURL,
|
||||
}
|
||||
|
||||
h.encoder.StatusResponse(ctx, w, conf, http.StatusOK)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue