autobrr/internal/http/config.go
Ludvig Lundgren 4d40d41628
Refactor irc client (#19)
* refactor: update http handlers

* feat: add trace log level

* refactir: irc handler

* refactor(definitions): add irc settings and invite cmd:

* feat: add dft values to inputs

* refactor: indexer irc forms

* refactor(definitions): fix nickserv.password var:

* feat: pre fill indexer name field

* refactor: handle stopping and updates
2021-08-29 23:23:02 +02:00

45 lines
838 B
Go

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 newConfigHandler(encoder encoder) *configHandler {
return &configHandler{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)
}