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