parent
39e16ce408
commit
d7e856aca2
|
@ -22,4 +22,7 @@ LISTEN=":8080"
|
||||||
|
|
||||||
# Basic Security, these are required to view the data
|
# Basic Security, these are required to view the data
|
||||||
IDENTITY_USERNAME=admin
|
IDENTITY_USERNAME=admin
|
||||||
IDENTITY_PASSWORD=admin
|
IDENTITY_PASSWORD=admin
|
||||||
|
|
||||||
|
# Enable/Disable debug features
|
||||||
|
DEBUG_MODE=false
|
|
@ -16,6 +16,8 @@ type DHConfig struct {
|
||||||
|
|
||||||
IdentityUsername string `json:"identityUsername"`
|
IdentityUsername string `json:"identityUsername"`
|
||||||
IdentityPassword string `json:"identityPassword"`
|
IdentityPassword string `json:"identityPassword"`
|
||||||
|
|
||||||
|
DebugMode bool `json:"debugMode"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetConfiguration() DHConfig {
|
func GetConfiguration() DHConfig {
|
||||||
|
@ -64,5 +66,11 @@ func GetConfiguration() DHConfig {
|
||||||
config.IdentityPassword = val
|
config.IdentityPassword = val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if val, exists := os.LookupEnv("DEBUG_MODE"); exists {
|
||||||
|
if isDebug, err := strconv.ParseBool(val); err == nil {
|
||||||
|
config.DebugMode = isDebug
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package web
|
package web
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
@ -30,7 +29,6 @@ func setupApi(r *gin.Engine) {
|
||||||
var olderThan, newerThan *time.Time
|
var olderThan, newerThan *time.Time
|
||||||
|
|
||||||
if ot := ctx.Query("older"); ot != "" {
|
if ot := ctx.Query("older"); ot != "" {
|
||||||
fmt.Printf("ot = %s\n", ot)
|
|
||||||
if otInt, err := strconv.ParseInt(ot, 10, 64); err == nil {
|
if otInt, err := strconv.ParseInt(ot, 10, 64); err == nil {
|
||||||
otTime := time.UnixMilli(otInt)
|
otTime := time.UnixMilli(otInt)
|
||||||
olderThan = &otTime
|
olderThan = &otTime
|
||||||
|
@ -38,16 +36,12 @@ func setupApi(r *gin.Engine) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if nt := ctx.Query("newer"); nt != "" {
|
if nt := ctx.Query("newer"); nt != "" {
|
||||||
fmt.Printf("nt = %s\n", nt)
|
|
||||||
if ntInt, err := strconv.ParseInt(nt, 10, 64); err == nil {
|
if ntInt, err := strconv.ParseInt(nt, 10, 64); err == nil {
|
||||||
ntTime := time.UnixMilli(ntInt)
|
ntTime := time.UnixMilli(ntInt)
|
||||||
newerThan = &ntTime
|
newerThan = &ntTime
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("olderThan = %s\n", olderThan)
|
|
||||||
fmt.Printf("newerThan = %s\n", newerThan)
|
|
||||||
|
|
||||||
graphData, err := svc.GetDiskGraphImage(diskId, newerThan, olderThan)
|
graphData, err := svc.GetDiskGraphImage(diskId, newerThan, olderThan)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.AbortWithStatusJSON(500, gin.H{
|
ctx.AbortWithStatusJSON(500, gin.H{
|
||||||
|
|
|
@ -6,12 +6,15 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func SetupRouter() *gin.Engine {
|
func SetupRouter() *gin.Engine {
|
||||||
// Initialize the Gin engine
|
|
||||||
cfg := config.GetConfiguration()
|
cfg := config.GetConfiguration()
|
||||||
r := gin.Default()
|
|
||||||
|
|
||||||
// Set gin to release
|
if !cfg.DebugMode {
|
||||||
gin.SetMode(gin.ReleaseMode)
|
// Set gin to release
|
||||||
|
gin.SetMode(gin.ReleaseMode)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize the Gin engine
|
||||||
|
r := gin.Default()
|
||||||
|
|
||||||
r.Use(BasicAuthMiddleware(cfg.IdentityUsername, cfg.IdentityPassword))
|
r.Use(BasicAuthMiddleware(cfg.IdentityUsername, cfg.IdentityPassword))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue