안쓰는 코드 정리 및 bson을 json으로 통일. 추후 gob으로 변경 예정
This commit is contained in:
11
server.go
11
server.go
@ -2,6 +2,7 @@ package gocommon
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/gob"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@ -26,7 +27,6 @@ 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"
|
||||
)
|
||||
|
||||
@ -430,12 +430,17 @@ func ReadStringFormValue(r url.Values, key string) (string, bool) {
|
||||
return strval, len(strval) > 0
|
||||
}
|
||||
|
||||
func ReadBsonDocumentFromBody[T any](r io.Reader, out *T) error {
|
||||
func DecodeGob[T any](r io.Reader, out *T) error {
|
||||
dec := gob.NewDecoder(r)
|
||||
return dec.Decode(out)
|
||||
}
|
||||
|
||||
func ReadJsonDocumentFromBody[T any](r io.Reader, out *T) error {
|
||||
bt, err := io.ReadAll(r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return bson.Unmarshal(bt, out)
|
||||
return json.Unmarshal(bt, out)
|
||||
}
|
||||
|
||||
func DotStringToTimestamp(tv string) primitive.Timestamp {
|
||||
|
||||
Reference in New Issue
Block a user