Add sample display logs from server.WIP
This commit is contained in:
parent
cc3e146cc2
commit
b2ab74434f
3 changed files with 55 additions and 19 deletions
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
|
@ -191,7 +192,22 @@ func (s *Server) createHandler() {
|
|||
})
|
||||
|
||||
r.Get("/dllog", func(w http.ResponseWriter, r *http.Request) {
|
||||
changelog_path := "cofffeemachineConfig/changelog/testlog.html"
|
||||
logFile, err := os.Open(changelog_path)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
defer logFile.Close()
|
||||
|
||||
w.Header().Set("Content-Disposition", "attachment; filename=logfile.html")
|
||||
w.Header().Set("Content-Type", "application/octet-stream")
|
||||
|
||||
_, err = io.Copy(w, logFile)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
})
|
||||
// Recipe Router
|
||||
rr := routers.NewRecipeRouter(database)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue