mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 12:42:34 +02:00
fix: build error
This commit is contained in:
parent
104e1b1d0a
commit
bf429998e8
7 changed files with 15 additions and 16 deletions
|
@ -25,7 +25,7 @@ func (d *dockerInfo) MarshalJSON() ([]byte, error) {
|
|||
},
|
||||
"images": d.Images,
|
||||
"n_cpu": d.NCPU,
|
||||
"memory": strutils.FormatByteSizeWithUnit(d.MemTotal),
|
||||
"memory": strutils.FormatByteSize(d.MemTotal),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/yusing/go-proxy/pkg/json"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// baseError is an immutable wrapper around an error.
|
||||
|
@ -49,6 +49,6 @@ func (err *baseError) Error() string {
|
|||
return err.Err.Error()
|
||||
}
|
||||
|
||||
func (err *baseError) MarshalJSONTo(buf []byte) []byte {
|
||||
return json.MarshalTo(err.Err, buf)
|
||||
func (err *baseError) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(err.Err)
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/yusing/go-proxy/pkg/json"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/yusing/go-proxy/internal/utils/strutils/ansi"
|
||||
)
|
||||
|
@ -94,7 +94,7 @@ func (err *withSubject) Error() string {
|
|||
return sb.String()
|
||||
}
|
||||
|
||||
func (err *withSubject) MarshalJSONTo(buf []byte) []byte {
|
||||
func (err *withSubject) MarshalJSON() ([]byte, error) {
|
||||
subjects := slices.Clone(err.Subjects)
|
||||
slices.Reverse(subjects)
|
||||
|
||||
|
@ -102,5 +102,5 @@ func (err *withSubject) MarshalJSONTo(buf []byte) []byte {
|
|||
"subjects": subjects,
|
||||
"err": err.Err,
|
||||
}
|
||||
return json.MarshalTo(reversed, buf)
|
||||
return json.Marshal(reversed)
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/yusing/go-proxy/pkg/json"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
func newError(message string) error {
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
"github.com/yusing/go-proxy/internal/logging"
|
||||
"github.com/yusing/go-proxy/internal/net/gphttp"
|
||||
"github.com/yusing/go-proxy/internal/net/gphttp/httpheaders"
|
||||
"github.com/yusing/go-proxy/internal/utils"
|
||||
)
|
||||
|
||||
func warnNoMatchDomains() {
|
||||
|
@ -95,7 +94,7 @@ func WriteText(r *http.Request, conn *websocket.Conn, msg string) bool {
|
|||
func DynamicJSONHandler[ResultType any](w http.ResponseWriter, r *http.Request, getter func() ResultType, interval time.Duration) {
|
||||
if httpheaders.IsWebsocket(r.Header) {
|
||||
Periodic(w, r, interval, func(conn *websocket.Conn) error {
|
||||
return wsjson.Write(r.Context(), conn, utils.ToJSONObject(getter()))
|
||||
return wsjson.Write(r.Context(), conn, getter())
|
||||
})
|
||||
} else {
|
||||
gphttp.RespondJSON(w, r, getter())
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net"
|
||||
|
@ -22,12 +21,12 @@ import (
|
|||
type SerializedObject = map[string]any
|
||||
|
||||
type (
|
||||
MapMarshaller interface {
|
||||
MapMarshaler interface {
|
||||
MarshalMap() map[string]any
|
||||
}
|
||||
MapUnmarshaller interface {
|
||||
UnmarshalMap(m map[string]any) gperr.Error
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -51,9 +50,10 @@ var (
|
|||
typeURL = reflect.TypeFor[url.URL]()
|
||||
typeCIDR = reflect.TypeFor[net.IPNet]()
|
||||
|
||||
typeMapMarshaller = reflect.TypeFor[MapMarshaller]()
|
||||
typeMapMarshaller = reflect.TypeFor[MapMarshaler]()
|
||||
typeMapUnmarshaler = reflect.TypeFor[MapUnmarshaller]()
|
||||
typeJSONMarshaller = reflect.TypeFor[json.Marshaler]()
|
||||
typeStrParser = reflect.TypeFor[strutils.Parser]()
|
||||
|
||||
typeAny = reflect.TypeOf((*any)(nil)).Elem()
|
||||
)
|
||||
|
|
|
@ -24,7 +24,7 @@ type (
|
|||
task.TaskStarter
|
||||
task.TaskFinisher
|
||||
fmt.Stringer
|
||||
utils.MapMarshaller
|
||||
utils.MapMarshaler
|
||||
WithHealthInfo
|
||||
Name() string
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue