Documentation ¶
Index ¶
- Constants
- Variables
- func CtxGetCorrelationID(ctx context.Context) string
- func CtxGetTenantID(ctx context.Context) int64
- func CtxSetCorrelationID(ctx context.Context, value string) context.Context
- func CtxSetTenantID(ctx context.Context, value int64) context.Context
- func DecodeGRPCContactRequest(ctx context.Context, r any) (any, error)
- func DecodeGRPCDeleteContactRequest(ctx context.Context, r any) (any, error)
- func DecodeGRPCListContactsRequest(ctx context.Context, r any) (any, error)
- func DecodeGRPCReadContactRequest(ctx context.Context, r any) (any, error)
- func Decrypt[T any](obj T, privateKey *rsa.PrivateKey) (T, error)
- func DecryptString(msg string, privateKey *rsa.PrivateKey) (string, error)
- func EncodeGRPCContactResponse(ctx context.Context, r any) (any, error)
- func EncodeGRPCListContactsResponse(ctx context.Context, r any) (any, error)
- func Encrypt[T any](obj T, publicKey *rsa.PublicKey) (T, error)
- func EncryptString(msg string, publicKey *rsa.PublicKey) (string, error)
- func MakeEndpoints(srv Service) clientapi.Endpoints
- func NewGRPCServer(ctx context.Context, endpoints clientapi.Endpoints) pb.AddressBookServer
- func NewHTTPServer(ctx context.Context, endpoints clientapi.Endpoints) http.Handler
- type Contact
- type Repository
- type Service
- type StandardPayloadError
- type StandardPayloadResponse
Constants ¶
const ContactMaxPageSize = 10
Variables ¶
Functions ¶
func CtxGetCorrelationID ¶
func CtxGetTenantID ¶
func CtxSetCorrelationID ¶
func DecodeGRPCContactRequest ¶
gRPC server method Decode from protobuf to domain object
func DecodeGRPCDeleteContactRequest ¶
gRPC server method Decode from protobuf to domain object
func DecodeGRPCListContactsRequest ¶
gRPC server method Decode from protobuf to domain object
func DecodeGRPCReadContactRequest ¶
gRPC server method Decode from protobuf to domain object
func Decrypt ¶
func Decrypt[T any](obj T, privateKey *rsa.PrivateKey) (T, error)
References: https://www.sohamkamani.com/golang/rsa-encryption/#decryption
func DecryptString ¶
func DecryptString(msg string, privateKey *rsa.PrivateKey) (string, error)
func EncodeGRPCContactResponse ¶
gRPC server method Encode from domain object to protobuf
func EncodeGRPCListContactsResponse ¶
gRPC server method Encode from domain object to protobuf
func Encrypt ¶
Possible solution for larger message sizes (limit is 190 bytes with 2048 key and SHA256): https://www.nsoftware.com/kb/xml/09051401.rst
func MakeEndpoints ¶
func NewGRPCServer ¶
Types ¶
type Repository ¶
type Repository interface { CreateContact(ctx context.Context, input *clientapi.ContactRequest) (output *clientapi.ContactResponse, err error) ReadContact(ctx context.Context, input *clientapi.ReadContactRequest) (output *clientapi.ContactResponse, err error) ListContacts(ctx context.Context, input *clientapi.ListContactsRequest) (output *clientapi.ListContactsResponse, err error) UpdateContact(ctx context.Context, input *clientapi.ContactRequest) (output *clientapi.ContactResponse, err error) DeleteContact(ctx context.Context, input *clientapi.DeleteContactRequest) (output *clientapi.ContactResponse, err error) }
func NewInMemoryRepository ¶
func NewInMemoryRepository() Repository
type Service ¶
type Service interface { CreateContact(ctx context.Context, input *clientapi.ContactRequest) (output *clientapi.ContactResponse, err error) ReadContact(ctx context.Context, input *clientapi.ReadContactRequest) (output *clientapi.ContactResponse, err error) ListContacts(ctx context.Context, input *clientapi.ListContactsRequest) (output *clientapi.ListContactsResponse, err error) UpdateContact(ctx context.Context, input *clientapi.ContactRequest) (output *clientapi.ContactResponse, err error) DeleteContact(ctx context.Context, input *clientapi.DeleteContactRequest) (output *clientapi.ContactResponse, err error) }
func NewService ¶
func NewService(repo Repository, privateKey *rsa.PrivateKey) Service
Look at https://betterstack.com/community/guides/logging/zerolog/#using-zerolog-in-a-web-application for setting up a logger you can "Get" that is preconfigured. https://betterstack.com/community/guides/logging/zerolog/#creating-a-logging-middleware
type StandardPayloadError ¶
type StandardPayloadResponse ¶
type StandardPayloadResponse struct { Data []any `json:"data"` NextPageToken int64 `json:"next_page_token"` Errors []StandardPayloadError `json:"errors"` CorrelationID string `json:"correlation_id"` }