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