mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-16 15:26:40 +00:00
return empty domain list when none in database
This commit is contained in:
@@ -56,6 +56,10 @@ func (h *handler) getAllDomains(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
domains, err := h.manager.GetDomains(r.Context(), userAuth.AccountId)
|
||||
if err != nil {
|
||||
util.WriteError(r.Context(), err, w)
|
||||
return
|
||||
}
|
||||
|
||||
var ret []api.ReverseProxyDomain
|
||||
for _, d := range domains {
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"net"
|
||||
|
||||
"github.com/netbirdio/netbird/management/server/types"
|
||||
"github.com/netbirdio/netbird/shared/management/status"
|
||||
)
|
||||
|
||||
type domainType string
|
||||
@@ -58,8 +59,10 @@ func (m Manager) GetDomains(ctx context.Context, accountID string) ([]*Domain, e
|
||||
return nil, fmt.Errorf("list free domains: %w", err)
|
||||
}
|
||||
domains, err := m.store.ListCustomDomains(ctx, accountID)
|
||||
if err != nil {
|
||||
// TODO: check for "no records" type error. Because that is a success condition.
|
||||
if statusErr, ok := status.FromError(err); ok && statusErr.Type() == status.NotFound {
|
||||
// This is fine, make sure domains are correctly set and continue.
|
||||
domains = make([]*Domain, 0)
|
||||
} else if err != nil {
|
||||
return nil, fmt.Errorf("list custom domains: %w", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,8 @@ func RegisterEndpoints(manager reverseproxy.Manager, domainManager domain.Manage
|
||||
router.HandleFunc("/reverse-proxies/{proxyId}", h.deleteReverseProxy).Methods("DELETE", "OPTIONS")
|
||||
|
||||
// Hang domain endpoints off the main router here.
|
||||
domain.RegisterEndpoints(router.PathPrefix("/reverse-proxies").Subrouter(), domainManager)
|
||||
domainRouter := router.PathPrefix("/reverse-proxies").Subrouter()
|
||||
domain.RegisterEndpoints(domainRouter, domainManager)
|
||||
}
|
||||
|
||||
func (h *handler) getAllReverseProxies(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user