mirror of
https://github.com/coalaura/whiskr.git
synced 2025-12-02 20:22:52 +00:00
better searching
This commit is contained in:
28
main.go
28
main.go
@@ -1,13 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/coalaura/logger"
|
||||
adapter "github.com/coalaura/logger/http"
|
||||
@@ -46,17 +42,6 @@ func main() {
|
||||
r.Get("/-/stats/{id}", HandleStats)
|
||||
r.Post("/-/chat", HandleChat)
|
||||
|
||||
if !NoOpen {
|
||||
time.AfterFunc(500*time.Millisecond, func() {
|
||||
log.Info("Opening browser...")
|
||||
|
||||
err := open("http://localhost:3443/")
|
||||
if err != nil {
|
||||
log.WarningE(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
log.Info("Listening at http://localhost:3443/")
|
||||
http.ListenAndServe(":3443", r)
|
||||
}
|
||||
@@ -73,16 +58,3 @@ func cache(next http.Handler) http.Handler {
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
||||
func open(url string) error {
|
||||
switch runtime.GOOS {
|
||||
case "linux":
|
||||
return exec.Command("xdg-open", url).Start()
|
||||
case "windows":
|
||||
return exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
|
||||
case "darwin":
|
||||
return exec.Command("open", url).Start()
|
||||
}
|
||||
|
||||
return errors.New("unsupported platform")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user