Add sample display logs from server.WIP

This commit is contained in:
pakintada@gmail.com 2023-09-20 15:37:07 +07:00
parent cc3e146cc2
commit b2ab74434f
3 changed files with 55 additions and 19 deletions

View file

@ -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)