Documentation
¶
Index ¶
- func ReadFromRequestBody(request *http.Request, result interface{})
- func ToSpendingResponse(spending domain.Spending) web.SpendingResponse
- func ToSpendingResponses(spendings []domain.Spending) []web.SpendingResponse
- func ToUserResponse(user domain.User) web.UserResponse
- func ToUserResponses(users []domain.User) []web.UserResponse
- func WriteToResponseBody(writer http.ResponseWriter, response interface{})
- type DynamoDB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadFromRequestBody ¶
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.