package Messages import ( "encoding/json" "net/http" "git.tovijaeschke.xyz/tovi/Envelope/Backend/Database" "git.tovijaeschke.xyz/tovi/Envelope/Backend/Models" "github.com/gorilla/mux" ) func ConversationDetail(w http.ResponseWriter, r *http.Request) { var ( conversationDetail Models.ConversationDetail urlVars map[string]string threadKey string returnJson []byte ok bool err error ) urlVars = mux.Vars(r) threadKey, ok = urlVars["threadKey"] if !ok { http.Error(w, "Not Found", http.StatusNotFound) return } conversationDetail, err = Database.GetConversationDetailById(threadKey) if !ok { http.Error(w, "Not Found", http.StatusNotFound) return } returnJson, err = json.MarshalIndent(conversationDetail, "", " ") if err != nil { http.Error(w, "Error", http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) w.Write(returnJson) }