mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-25 01:38:30 +02:00
refactor: improve error handling, validation and proper cleanup
This commit is contained in:
@@ -218,7 +218,7 @@ func (r *Route) validate() gperr.Error {
|
||||
r.Proxmox.VMName = res.Name
|
||||
|
||||
if r.Host == DefaultHost {
|
||||
containerName := r.Idlewatcher.ContainerName()
|
||||
containerName := res.Name
|
||||
// get ip addresses of the vmid
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
@@ -336,7 +336,7 @@ func (r *Route) validate() gperr.Error {
|
||||
}
|
||||
}
|
||||
|
||||
if r.Proxmox == nil && r.Container == nil {
|
||||
if r.Proxmox == nil && r.Container == nil && r.ProxyURL != nil {
|
||||
proxmoxProviders := config.WorkingState.Load().Value().Providers.Proxmox
|
||||
if len(proxmoxProviders) > 0 {
|
||||
// it's fine if ip is nil
|
||||
|
||||
@@ -79,6 +79,10 @@ var commands = map[string]struct {
|
||||
},
|
||||
build: func(args any) CommandHandler {
|
||||
return NonTerminatingCommand(func(w http.ResponseWriter, r *http.Request) error {
|
||||
if authHandler == nil {
|
||||
http.Error(w, "Auth handler not initialized", http.StatusInternalServerError)
|
||||
return errTerminated
|
||||
}
|
||||
if !authHandler(w, r) {
|
||||
return errTerminated
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user