Compare commits
2 Commits
7aef03a7cd
...
v0.0.23
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e05c3a06ae | ||
|
|
5e551b4eaf |
6
env/enviroment.go
vendored
6
env/enviroment.go
vendored
@@ -26,7 +26,11 @@ func Load(path string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (key EnvKey) GetValue() string {
|
func (key EnvKey) GetValue() string {
|
||||||
return os.Getenv(string(key))
|
port := os.Getenv(string(key))
|
||||||
|
if port == "" {
|
||||||
|
port = "8080"
|
||||||
|
}
|
||||||
|
return port
|
||||||
}
|
}
|
||||||
|
|
||||||
func (key EnvKey) SetValue(value string) {
|
func (key EnvKey) SetValue(value string) {
|
||||||
|
|||||||
@@ -34,20 +34,16 @@ func getActiveIP() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func InfoHandler(w http.ResponseWriter, r *http.Request) {
|
func InfoHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
port := env.Port.GetValue()
|
w.Header().Set("Content-Type", "application/json")
|
||||||
if port == "" {
|
|
||||||
port = "8080"
|
|
||||||
}
|
|
||||||
|
|
||||||
speed := env.IntervalDefault.GetValue()
|
|
||||||
if speed == "" {
|
|
||||||
speed = "10"
|
|
||||||
}
|
|
||||||
|
|
||||||
data := map[string]string{
|
data := map[string]string{
|
||||||
"ip": GetLocalIP(),
|
"ip": GetLocalIP(),
|
||||||
"port": port,
|
"port": env.Port.GetValue(),
|
||||||
"speed": GetInterval(),
|
"speed": GetInterval(),
|
||||||
}
|
}
|
||||||
json.NewEncoder(w).Encode(data)
|
err := json.NewEncoder(w).Encode(data)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user