Start cleaning up linter errors. (#358)
* Start cleaning up linter errors. For #357 * Fix unmarshalling NullTime values * More linter fixes * Remove commented code * Move defer up * Consolidate error check lines * Move error check to make sure row iteration was successful * Cleaner error check + do not recreate pipe if it exists * Consolidate hashing to generate client id
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/owncast/owncast/core"
|
||||
"github.com/owncast/owncast/models"
|
||||
"github.com/owncast/owncast/router/middleware"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// GetChatMessages gets all of the chat messages.
|
||||
@@ -17,7 +18,10 @@ func GetChatMessages(w http.ResponseWriter, r *http.Request) {
|
||||
case http.MethodGet:
|
||||
messages := core.GetAllChatMessages()
|
||||
|
||||
json.NewEncoder(w).Encode(messages)
|
||||
err := json.NewEncoder(w).Encode(messages)
|
||||
if err != nil {
|
||||
log.Errorln(err)
|
||||
}
|
||||
case http.MethodPost:
|
||||
var message models.ChatMessage
|
||||
if err := json.NewDecoder(r.Body).Decode(&message); err != nil {
|
||||
@@ -30,9 +34,14 @@ func GetChatMessages(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
json.NewEncoder(w).Encode(j{"success": true})
|
||||
if err := json.NewEncoder(w).Encode(j{"success": true}); err != nil {
|
||||
internalErrorHandler(w, err)
|
||||
return
|
||||
}
|
||||
default:
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
json.NewEncoder(w).Encode(j{"error": "method not implemented (PRs are accepted)"})
|
||||
if err := json.NewEncoder(w).Encode(j{"error": "method not implemented (PRs are accepted)"}); err != nil {
|
||||
internalErrorHandler(w, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user