mirror of
https://github.com/idanoo/autobrr
synced 2025-07-22 16:29:12 +00:00
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
This commit is contained in:
parent
5f69ae9380
commit
4d40d41628
48 changed files with 1380 additions and 943 deletions
|
@ -18,8 +18,15 @@ type downloadClientService interface {
|
|||
}
|
||||
|
||||
type downloadClientHandler struct {
|
||||
encoder encoder
|
||||
downloadClientService downloadClientService
|
||||
encoder encoder
|
||||
service downloadClientService
|
||||
}
|
||||
|
||||
func newDownloadClientHandler(encoder encoder, service downloadClientService) *downloadClientHandler {
|
||||
return &downloadClientHandler{
|
||||
encoder: encoder,
|
||||
service: service,
|
||||
}
|
||||
}
|
||||
|
||||
func (h downloadClientHandler) Routes(r chi.Router) {
|
||||
|
@ -33,7 +40,7 @@ func (h downloadClientHandler) Routes(r chi.Router) {
|
|||
func (h downloadClientHandler) listDownloadClients(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
clients, err := h.downloadClientService.List()
|
||||
clients, err := h.service.List()
|
||||
if err != nil {
|
||||
//
|
||||
}
|
||||
|
@ -52,7 +59,7 @@ func (h downloadClientHandler) store(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
client, err := h.downloadClientService.Store(data)
|
||||
client, err := h.service.Store(data)
|
||||
if err != nil {
|
||||
// encode error
|
||||
}
|
||||
|
@ -72,7 +79,7 @@ func (h downloadClientHandler) test(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
err := h.downloadClientService.Test(data)
|
||||
err := h.service.Test(data)
|
||||
if err != nil {
|
||||
// encode error
|
||||
h.encoder.StatusResponse(ctx, w, nil, http.StatusBadRequest)
|
||||
|
@ -93,7 +100,7 @@ func (h downloadClientHandler) update(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
client, err := h.downloadClientService.Store(data)
|
||||
client, err := h.service.Store(data)
|
||||
if err != nil {
|
||||
// encode error
|
||||
}
|
||||
|
@ -111,7 +118,7 @@ func (h downloadClientHandler) delete(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
id, _ := strconv.Atoi(clientID)
|
||||
|
||||
if err := h.downloadClientService.Delete(id); err != nil {
|
||||
if err := h.service.Delete(id); err != nil {
|
||||
// encode error
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue