Skip to content

Commit 9d626cc

Browse files
committed
devhttp: return the payload even if the script isn't http based
Returns the content as text/plain
1 parent 41f7164 commit 9d626cc

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

cmd/cli/cmd_devhttp.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,22 @@ func (p *devHttpProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
212212
if err != nil {
213213
log.WithFields(fields).Errorf("failed to write reply back to HTTP response: %v", err)
214214
}
215+
216+
return
215217
}
218+
219+
// Return the content of the script as if the browser was a console
220+
w.Header().Add("Content-Type", "text/plain")
221+
222+
// Only print error if there is one
223+
if res.Error != "" {
224+
w.WriteHeader(http.StatusInternalServerError)
225+
w.Write([]byte(res.Error))
226+
return
227+
}
228+
229+
w.WriteHeader(code)
230+
w.Write(res.Payload)
216231
}
217232

218233
func emptyStore(s store.ScriptStore, libraryDir string) {

0 commit comments

Comments
 (0)