Decouple chat from core and add chat rest api (#25)
* Decouple the chat package from the core * Add rest api endpoints for the chat aspect
This commit is contained in:
26
controllers/controllers.go
Normal file
26
controllers/controllers.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type j map[string]interface{}
|
||||
|
||||
func internalErrorHandler(w http.ResponseWriter, err error) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
json.NewEncoder(w).Encode(j{"error": err.Error()})
|
||||
}
|
||||
|
||||
func badRequestHandler(w http.ResponseWriter, err error) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
json.NewEncoder(w).Encode(j{"error": err.Error()})
|
||||
}
|
||||
Reference in New Issue
Block a user