helper

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadFromRequestBody

func ReadFromRequestBody(request *http.Request, result interface{})

ReadFromRequestBody reads the JSON data from the provided HTTP request's body and decode it into the specified result interface{}.

The function uses the json.NewDecoder from the encoding/json package to decode the JSON data.

func ToSpendingResponse

func ToSpendingResponse(spending domain.Spending) web.SpendingResponse

ToSpendingResponse converts a domain.Spending struct to a web.SpendingResponse struct.

This function is commonly used to transform user's spending information retrieved from process the data on the database into a format suitable for sending back as a response in API endpoints.

func ToSpendingResponses

func ToSpendingResponses(spendings []domain.Spending) []web.SpendingResponse

ToSpendingResponses converts a slice of domain.Spending struct to a slice of web.SpendingResponse struct.

This function is commonly used to transform multiple user's spending records retrieved from process the data on the database into a format suitable for sending back as a response in API endpoints.

func ToUserResponse

func ToUserResponse(user domain.User) web.UserResponse

ToUserResponse converts a domain.User struct to a web.UserResponse struct.

This function is commonly used to transform user information retrieved from process the data on the database into a format suitable for sending back as a response in API endpoints.

func ToUserResponses

func ToUserResponses(users []domain.User) []web.UserResponse

ToUserResponses converts a slice of domain.User struct to a slice of web.UserResponse struct.

This function is commonly used to transform multiple user records retrieved from process the data on the database into a format suitable for sending back as a response in API endpoints.

func WriteToResponseBody

func WriteToResponseBody(writer http.ResponseWriter, response interface{})

WriteToResponseBody writes the provided response data to the HTTP response writer in JSON format. It sets the "Content-Type" header to "application/json".

The function uses the json.NewEncoder from the encoding/json package to encode the response data.

Types

type DynamoDB

type DynamoDB struct {

	// Client is a pointer to a DynamoDB client that can be used
	// to perform database operation.
	// required
	Client *dynamodb.Client

	// TableName is the name of the DynamoDB table associated with
	// the instance.
	TableName string
}

DynamoDB represents a configuration for interacting with a DynamoDB database.

Jump to

Keyboard shortcuts

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