mirror of
https://github.com/yusing/godoxy.git
synced 2025-06-09 13:02:33 +02:00
fixed schema and json tag, hide http://:0
This commit is contained in:
parent
a278711421
commit
c847fe4747
5 changed files with 16 additions and 10 deletions
|
@ -16,9 +16,9 @@ import (
|
||||||
type ReverseProxyEntry struct { // real model after validation
|
type ReverseProxyEntry struct { // real model after validation
|
||||||
Raw *RawEntry `json:"raw"`
|
Raw *RawEntry `json:"raw"`
|
||||||
|
|
||||||
Alias fields.Alias `json:"alias,omitempty"`
|
Alias fields.Alias `json:"alias"`
|
||||||
Scheme fields.Scheme `json:"scheme,omitempty"`
|
Scheme fields.Scheme `json:"scheme"`
|
||||||
URL net.URL `json:"url,omitempty"`
|
URL net.URL `json:"url"`
|
||||||
NoTLSVerify bool `json:"no_tls_verify,omitempty"`
|
NoTLSVerify bool `json:"no_tls_verify,omitempty"`
|
||||||
PathPatterns fields.PathPatterns `json:"path_patterns,omitempty"`
|
PathPatterns fields.PathPatterns `json:"path_patterns,omitempty"`
|
||||||
HealthCheck *health.HealthCheckConfig `json:"healthcheck,omitempty"`
|
HealthCheck *health.HealthCheckConfig `json:"healthcheck,omitempty"`
|
||||||
|
|
|
@ -15,9 +15,9 @@ import (
|
||||||
type StreamEntry struct {
|
type StreamEntry struct {
|
||||||
Raw *RawEntry `json:"raw"`
|
Raw *RawEntry `json:"raw"`
|
||||||
|
|
||||||
Alias fields.Alias `json:"alias,omitempty"`
|
Alias fields.Alias `json:"alias"`
|
||||||
Scheme fields.StreamScheme `json:"scheme,omitempty"`
|
Scheme fields.StreamScheme `json:"scheme"`
|
||||||
URL net.URL `json:"url,omitempty"`
|
URL net.URL `json:"url"`
|
||||||
Host fields.Host `json:"host,omitempty"`
|
Host fields.Host `json:"host,omitempty"`
|
||||||
Port fields.StreamPort `json:"port,omitempty"`
|
Port fields.StreamPort `json:"port,omitempty"`
|
||||||
HealthCheck *health.HealthCheckConfig `json:"healthcheck,omitempty"`
|
HealthCheck *health.HealthCheckConfig `json:"healthcheck,omitempty"`
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/yusing/go-proxy/internal/common"
|
"github.com/yusing/go-proxy/internal/common"
|
||||||
E "github.com/yusing/go-proxy/internal/error"
|
E "github.com/yusing/go-proxy/internal/error"
|
||||||
"github.com/yusing/go-proxy/internal/proxy/entry"
|
"github.com/yusing/go-proxy/internal/proxy/entry"
|
||||||
|
@ -61,7 +62,9 @@ func (p *FileProvider) LoadRoutesImpl() (routes R.Routes, res E.Error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
b.Add(Validate(data), true)
|
if err := Validate(data); err != nil {
|
||||||
|
logrus.Warn(err)
|
||||||
|
}
|
||||||
|
|
||||||
return R.FromEntries(entries)
|
return R.FromEntries(entries)
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,10 @@ type JSONRepresentation struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (jsonRepr *JSONRepresentation) MarshalJSON() ([]byte, error) {
|
func (jsonRepr *JSONRepresentation) MarshalJSON() ([]byte, error) {
|
||||||
|
url := jsonRepr.URL.String()
|
||||||
|
if url == "http://:0" {
|
||||||
|
url = ""
|
||||||
|
}
|
||||||
return json.Marshal(map[string]any{
|
return json.Marshal(map[string]any{
|
||||||
"name": jsonRepr.Name,
|
"name": jsonRepr.Name,
|
||||||
"config": jsonRepr.Config,
|
"config": jsonRepr.Config,
|
||||||
|
@ -27,7 +31,7 @@ func (jsonRepr *JSONRepresentation) MarshalJSON() ([]byte, error) {
|
||||||
"status": jsonRepr.Status.String(),
|
"status": jsonRepr.Status.String(),
|
||||||
"uptime": jsonRepr.Uptime.Seconds(),
|
"uptime": jsonRepr.Uptime.Seconds(),
|
||||||
"uptimeStr": U.FormatDuration(jsonRepr.Uptime),
|
"uptimeStr": U.FormatDuration(jsonRepr.Uptime),
|
||||||
"url": jsonRepr.URL,
|
"url": url,
|
||||||
"extra": jsonRepr.Extra,
|
"extra": jsonRepr.Extra,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,8 +122,7 @@
|
||||||
"properties": {
|
"properties": {
|
||||||
"link": {
|
"link": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Name and subdomain of load-balancer",
|
"description": "Name and subdomain of load-balancer"
|
||||||
"format": "uri"
|
|
||||||
},
|
},
|
||||||
"mode": {
|
"mode": {
|
||||||
"enum": [
|
"enum": [
|
||||||
|
|
Loading…
Add table
Reference in a new issue