helpers

package
v0.0.0-...-476be57 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeDecryptRequest

func DecodeDecryptRequest(_ context.Context, r *http.Request) (interface{}, error)

DecodeDecryptRequest fills struct from JSON details of request

func DecodeEncryptRequest

func DecodeEncryptRequest(_ context.Context, r *http.Request) (interface{}, error)

DecodeEncryptRequest fills struct from JSON details of request

func EncodeResponse

func EncodeResponse(_ context.Context, w http.ResponseWriter, response interface{}) error

EncodeResponse is common for both the reponses from encrypt and decrypt services

func MakeDecryptEndpoint

func MakeDecryptEndpoint(svc EncryptService) endpoint.Endpoint

MakeDecryptEndpoint forms endpoint for request/response of decrypt function

func MakeEncryptEndpoint

func MakeEncryptEndpoint(svc EncryptService) endpoint.Endpoint

MakeEncryptEndpoint forms endpoint for request/response of encrypt function

Types

type DecryptRequest

type DecryptRequest struct {
	Message string `json:"message"`
	Key     string `json:"key"`
}

DecryptRequest strctures request coming from client

type DecryptResponse

type DecryptResponse struct {
	Text string `json:"text"`
	Err  string `json:"error"`
}

DecryptResponse strctures response going to the client

type EncryptRequest

type EncryptRequest struct {
	Text string `json:"text"`
	Key  string `json:"key"`
}

EncryptRequest strctures request coming from client

type EncryptResponse

type EncryptResponse struct {
	Message string `json:"message"`
	Err     string `json:"error"`
}

EncryptResponse strctures response going to the client

type EncryptService

type EncryptService interface {
	Encrypt(context.Context, string, string) (string, error)
	Decrypt(context.Context, string, string) (string, error)
}

EncryptService is a blueprint for our service

type EncryptServiceInstance

type EncryptServiceInstance struct{}

EncryptServiceInstance is the implementation of interface for micro service

func (EncryptServiceInstance) Decrypt

func (EncryptServiceInstance) Decrypt(_ context.Context, key string, text string) (string, error)

Decrypt decrypts the encrypted string to original

func (EncryptServiceInstance) Encrypt

func (EncryptServiceInstance) Encrypt(_ context.Context, key string, text string) (string, error)

Encrypt encrypts the string with given key

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL