fix: set content-type to json
This commit is contained in:
@ -62,6 +62,8 @@ func (h *AdminHandler) GetApiServices(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
encoder := json.NewEncoder(w)
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
if err := encoder.Encode(Response{
|
||||
Items: apiServices,
|
||||
Count: len(apiServices),
|
||||
@ -147,6 +149,9 @@ func (h *AdminHandler) AddApiService(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
encoder := json.NewEncoder(w)
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
if err := encoder.Encode(Response{
|
||||
Service: NewApiServiceDTO(service),
|
||||
Credentials: ApiServiceCredentials{
|
||||
@ -174,6 +179,8 @@ func (h *AdminHandler) GetApiService(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
encoder := json.NewEncoder(w)
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
if err := encoder.Encode(NewApiServiceDTO(service)); err != nil {
|
||||
web.Error(w, "failed to encode response", http.StatusInternalServerError)
|
||||
}
|
||||
@ -209,6 +216,8 @@ func (h *AdminHandler) RegenerateApiServiceSecret(w http.ResponseWriter, r *http
|
||||
|
||||
encoder := json.NewEncoder(w)
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
if err := encoder.Encode(ApiServiceCredentials{
|
||||
ClientId: service.ClientID,
|
||||
ClientSecret: clientSecret,
|
||||
@ -272,6 +281,8 @@ func (h *AdminHandler) UpdateApiService(w http.ResponseWriter, r *http.Request)
|
||||
|
||||
encoder := json.NewEncoder(w)
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
if err := encoder.Encode(NewApiServiceDTO(updated)); err != nil {
|
||||
web.Error(w, "failed to send updated api service", http.StatusInternalServerError)
|
||||
}
|
||||
|
@ -47,6 +47,8 @@ func (h *AdminHandler) GetUsers(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
encoder := json.NewEncoder(w)
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
if err := encoder.Encode(&Response{
|
||||
Items: items,
|
||||
Count: len(items),
|
||||
@ -71,6 +73,8 @@ func (h *AdminHandler) GetUser(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
encoder := json.NewEncoder(w)
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
if err := encoder.Encode(NewUserDTO(&user)); err != nil {
|
||||
web.Error(w, "failed to encode user dto", http.StatusInternalServerError)
|
||||
}
|
||||
|
Reference in New Issue
Block a user