2022-06-19 22:02:44 -07:00
|
|
|
package routes
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
|
|
"github.com/google/uuid"
|
|
|
|
)
|
|
|
|
|
|
|
|
// GetSettings
|
2022-07-12 15:28:31 -07:00
|
|
|
// @Summary Returns a object based on the Key that was given.
|
2022-06-19 22:02:44 -07:00
|
|
|
// @Param key path string true "Settings Key value"
|
|
|
|
// @Produce application/json
|
2022-07-12 15:28:31 -07:00
|
|
|
// @Tags Settings
|
2022-06-19 22:02:44 -07:00
|
|
|
// @Router /settings/{key} [get]
|
|
|
|
func (s *Server) getSettings(w http.ResponseWriter, r *http.Request) {
|
|
|
|
//var item model.Sources
|
|
|
|
id := chi.URLParam(r, "ID")
|
|
|
|
|
|
|
|
uuid, err := uuid.Parse(id)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
res, err := s.Db.GetSourceByID(*s.ctx, uuid)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
//itemId := fmt.Sprint(item.ID)
|
|
|
|
//if id != itemId {
|
|
|
|
// log.Panicln("Unable to find the requested record. Either unable to access SQL or the record does not exist.")
|
|
|
|
//}
|
|
|
|
|
|
|
|
bResult, err := json.Marshal(res)
|
|
|
|
if err != nil {
|
|
|
|
log.Panicln(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
|
|
w.Write(bResult)
|
|
|
|
}
|