2024-04-23 07:15:38 -07:00
|
|
|
package v1
|
2022-06-19 22:02:44 -07:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
|
|
"github.com/google/uuid"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s *Server) getSettings(w http.ResponseWriter, r *http.Request) {
|
2023-01-22 10:12:55 -08:00
|
|
|
// GetSettings
|
|
|
|
// @Summary Returns a object based on the Key that was given.
|
|
|
|
// @Param key path string true "Settings Key value"
|
|
|
|
// @Produce application/json
|
|
|
|
// @Tags Settings
|
|
|
|
// @Router /settings/{key} [get]
|
|
|
|
|
|
|
|
|
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
|
|
|
2022-06-19 22:02:44 -07:00
|
|
|
//var item model.Sources
|
|
|
|
id := chi.URLParam(r, "ID")
|
|
|
|
|
|
|
|
uuid, err := uuid.Parse(id)
|
|
|
|
if err != nil {
|
2023-01-22 10:12:55 -08:00
|
|
|
s.WriteError(w, err.Error(), http.StatusBadRequest)
|
|
|
|
return
|
2022-06-19 22:02:44 -07:00
|
|
|
}
|
|
|
|
|
2023-01-31 12:39:54 -08:00
|
|
|
res, err := s.Db.GetSourceByID(r.Context(), uuid)
|
2022-06-19 22:02:44 -07:00
|
|
|
if err != nil {
|
2023-01-22 10:12:55 -08:00
|
|
|
s.WriteError(w, err.Error(), http.StatusNotFound)
|
|
|
|
return
|
2022-06-19 22:02:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bResult, err := json.Marshal(res)
|
|
|
|
if err != nil {
|
2023-01-22 10:12:55 -08:00
|
|
|
s.WriteError(w, err.Error(), http.StatusInternalServerError)
|
|
|
|
return
|
2022-06-19 22:02:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
w.Write(bResult)
|
2022-12-04 08:49:17 -08:00
|
|
|
}
|