Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
skhaz committed Nov 9, 2023
1 parent 1cebb39 commit 5ce98fd
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,29 @@ import (
)

type Message struct {
Text string `json:"message"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
}

func handler(w http.ResponseWriter, r *http.Request) {
cmd := exec.Command("cmake", "--build", ".")
cmd.Dir = "/opt/carimbo/build"
var stdout, stderr bytes.Buffer

var out bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
cmd.Run()
// err := cmd.Run()
// if err != nil {
// w.Header().Set("Content-Type", "application/json")
// json.NewEncoder(w).Encode(message)

cmd.Stdout = &out

err := cmd.Run()
if err != nil {
message := Message{
Text: err.Error(),
}

w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(message)

return
}

output := out.String()
// return
// }

message := Message{
Text: output,
Stdout: stdout.String(),
Stderr: stderr.String(),
}

w.Header().Set("Content-Type", "application/json")
Expand Down

0 comments on commit 5ce98fd

Please sign in to comment.