Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter committed Jun 28, 2024
1 parent 2767b17 commit 9541bf0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion example-app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func exampleWithWebserver() {

logger = logdy.InitializeLogdy(logdy.Config{
HttpPathPrefix: "/_logdy-ui",
LogLevel: logdy.LOG_LEVEL_VERBOSE,
LogLevel: logdy.LOG_LEVEL_NORMAL,
}, nil)

log.Fatal(http.ListenAndServe(":8080", nil))
Expand Down
6 changes: 5 additions & 1 deletion http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"net/http"
"reflect"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -384,7 +385,8 @@ func HandleHttp(config *Config, clients *ClientsStruct, serveMux hand) {
// Use the file system to serve static files
fs := http.FileServer(http.FS(assets))

if serveMux == nil {
if reflect.ValueOf(serveMux).IsNil() {
utils.Logger.Debug("Using net/http")
http.Handle(config.HttpPathPrefix, http.StripPrefix(config.HttpPathPrefix, fs))
http.HandleFunc(config.HttpPathPrefix+"api/check-pass", handleCheckPass(config.UiPass))
http.HandleFunc(config.HttpPathPrefix+"api/status", handleStatus(config))
Expand All @@ -393,6 +395,7 @@ func HandleHttp(config *Config, clients *ClientsStruct, serveMux hand) {
http.HandleFunc(config.HttpPathPrefix+"api/client/peek-log", handleClientPeek(clients))
http.HandleFunc(config.HttpPathPrefix+"ws", handleWs(config.UiPass, clients))
} else {
utils.Logger.Debug("Using serveMux", serveMux)
serveMux.Handle(config.HttpPathPrefix, http.StripPrefix(config.HttpPathPrefix, fs))
serveMux.HandleFunc(config.HttpPathPrefix+"api/check-pass", handleCheckPass(config.UiPass))
serveMux.HandleFunc(config.HttpPathPrefix+"api/status", handleStatus(config))
Expand All @@ -405,6 +408,7 @@ func HandleHttp(config *Config, clients *ClientsStruct, serveMux hand) {
}

func StartWebserver(config *Config) {
utils.Logger.Debug("Starting webserver")
utils.Logger.WithFields(logrus.Fields{
"port": config.ServerPort,
}).Info("WebUI started, visit http://" + config.ServerIp + ":" + config.ServerPort + config.HttpPathPrefix)
Expand Down

1 comment on commit 9541bf0

@chenrui333
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note, this commit got tagged but not marked as latest release

relates to Homebrew/homebrew-core#175870

Please sign in to comment.