forked from CWAD/relibre
Fixup README
This commit is contained in:
6
main.go
6
main.go
@@ -21,7 +21,6 @@ import (
|
||||
webview "github.com/webview/webview_go"
|
||||
)
|
||||
|
||||
//go:embed index.html ui/* images/*
|
||||
var content embed.FS
|
||||
|
||||
type saveReq struct {
|
||||
@@ -34,7 +33,6 @@ type saveResp struct {
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Static files
|
||||
subFS, err := fs.Sub(content, ".")
|
||||
if err != nil {
|
||||
log.Fatalf("fs.Sub error: %v", err)
|
||||
@@ -42,7 +40,6 @@ func main() {
|
||||
mux := http.NewServeMux()
|
||||
mux.Handle("/", http.FileServer(http.FS(subFS)))
|
||||
|
||||
// /save endpoint writes to Downloads
|
||||
mux.HandleFunc("/save", func(w http.ResponseWriter, r *http.Request) {
|
||||
start := time.Now()
|
||||
defer func() { log.Printf("%s %s %s", r.Method, r.URL.Path, time.Since(start)) }()
|
||||
@@ -77,14 +74,12 @@ func main() {
|
||||
_ = json.NewEncoder(w).Encode(saveResp{Path: path})
|
||||
})
|
||||
|
||||
// Simple request logger
|
||||
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
start := time.Now()
|
||||
mux.ServeHTTP(w, r)
|
||||
log.Printf("%s %s %s", r.Method, r.URL.Path, time.Since(start))
|
||||
})
|
||||
|
||||
// Start server on ephemeral port
|
||||
ln, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
if err != nil {
|
||||
log.Fatalf("listen: %v", err)
|
||||
@@ -99,7 +94,6 @@ func main() {
|
||||
}
|
||||
}()
|
||||
|
||||
// Native webview window (debug true for dev tools/log signals)
|
||||
debug := true
|
||||
w := webview.New(debug)
|
||||
defer w.Destroy()
|
||||
|
||||
Reference in New Issue
Block a user