Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,14 @@ func handleService(w http.ResponseWriter, r *http.Request) {
err = json.Unmarshal(bodyData, &webCall)
if err != nil {
http.Error(w, fmt.Sprintf("invalid request body: %v", err), http.StatusBadRequest)
return
}

rtn := service.CallService(r.Context(), webCall)
jsonRtn, err := json.Marshal(rtn)
if err != nil {
http.Error(w, fmt.Sprintf("error serializing response: %v", err), http.StatusInternalServerError)
return
}
w.Header().Set(ContentTypeHeaderKey, ContentTypeJson)
w.Header().Set(ContentLengthHeaderKey, fmt.Sprintf("%d", len(jsonRtn)))
Expand Down Expand Up @@ -157,6 +159,7 @@ func handleWaveFile(w http.ResponseWriter, r *http.Request) {
offset, err = strconv.ParseInt(offsetStr, 10, 64)
if err != nil {
http.Error(w, fmt.Sprintf("invalid offset: %v", err), http.StatusBadRequest)
return
}
}
if _, err := uuid.Parse(zoneId); err != nil {
Expand All @@ -180,6 +183,7 @@ func handleWaveFile(w http.ResponseWriter, r *http.Request) {
jsonFileBArr, err := json.Marshal(file)
if err != nil {
http.Error(w, fmt.Sprintf("error serializing file info: %v", err), http.StatusInternalServerError)
return
}
// can make more efficient by checking modtime + If-Modified-Since headers to allow caching
dataStartIdx := file.DataStartIdx()
Expand Down Expand Up @@ -239,6 +243,7 @@ func handleLocalStreamFile(w http.ResponseWriter, r *http.Request, path string,
path, err := wavebase.ExpandHomeDir(path)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
http.ServeFile(w, r, path)
}
Expand Down