ReadBsonDocumentFromBody로 교체
This commit is contained in:
11
server.go
11
server.go
@ -26,6 +26,7 @@ import (
|
|||||||
"repositories.action2quare.com/ayo/gocommon/logger"
|
"repositories.action2quare.com/ayo/gocommon/logger"
|
||||||
|
|
||||||
"github.com/pires/go-proxyproto"
|
"github.com/pires/go-proxyproto"
|
||||||
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -429,10 +430,12 @@ func ReadStringFormValue(r url.Values, key string) (string, bool) {
|
|||||||
return strval, len(strval) > 0
|
return strval, len(strval) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadJsonDocumentFromBody(r io.Reader) (out map[string]any) {
|
func ReadBsonDocumentFromBody[T any](r io.Reader, out *T) error {
|
||||||
dec := json.NewDecoder(r)
|
bt, err := io.ReadAll(r)
|
||||||
dec.Decode(&out)
|
if err != nil {
|
||||||
return
|
return err
|
||||||
|
}
|
||||||
|
return bson.Unmarshal(bt, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DotStringToTimestamp(tv string) primitive.Timestamp {
|
func DotStringToTimestamp(tv string) primitive.Timestamp {
|
||||||
|
|||||||
Reference in New Issue
Block a user