Documentation
¶
Index ¶
- Constants
- func BadRequestResponse(message ...string) (events.APIGatewayProxyResponse, error)
- func BodyToJSON[T any](body T) (string, error)
- func InternalServerErrorResponse(message ...string) (events.APIGatewayProxyResponse, error)
- func JSONtoBody[T any](jsonStr string, body *T) error
- func NewRequestBody[T any](proxyRequest events.APIGatewayProxyRequest, additionalData T) (T, error)
- func NotFoundResponse(message ...string) (events.APIGatewayProxyResponse, error)
- func SuccessResponse(body interface{}) (events.APIGatewayProxyResponse, error)
- func UnauthorizedResponse(message ...string) (events.APIGatewayProxyResponse, error)
- type DefaultBody
- type HTTPRequestsUtils
- type HTTPResponse
Constants ¶
View Source
const ( StatusBadRequestDefaultMessage = "The request could not be understood by the server due to malformed syntax." StatusNotFoundDefaultMessage = "The requested resource could not be found." StatusInternalServerErrorDefaultMessage = "The server encountered an unexpected condition which prevented it from fulfilling the request." )
View Source
const ( StatusBadRequestDefaultCode = "BAD_REQUEST" StatusNotFoundDefaultCode = "NOT_FOUND" StatusInternalServerErrorDefaultCode = "INTERNAL_SERVER_ERROR" )
Variables ¶
This section is empty.
Functions ¶
func BadRequestResponse ¶
func BadRequestResponse(message ...string) (events.APIGatewayProxyResponse, error)
BadRequestResponse creates a bad request response (status code 400) with an optional message
func BodyToJSON ¶
func InternalServerErrorResponse ¶
func InternalServerErrorResponse(message ...string) (events.APIGatewayProxyResponse, error)
InternalServerErrorResponse creates an internal server error response (status code 500) with an optional message
func JSONtoBody ¶
func NewRequestBody ¶
func NewRequestBody[T any](proxyRequest events.APIGatewayProxyRequest, additionalData T) (T, error)
func NotFoundResponse ¶
func NotFoundResponse(message ...string) (events.APIGatewayProxyResponse, error)
NotFoundResponse creates a not found response (status code 404) with an optional message
func SuccessResponse ¶
func SuccessResponse(body interface{}) (events.APIGatewayProxyResponse, error)
SuccessResponse creates a successful response (status code 200) with a required body
func UnauthorizedResponse ¶
func UnauthorizedResponse(message ...string) (events.APIGatewayProxyResponse, error)
UnauthorizedResponse creates an unauthorized response (status code 401) with an optional message
Types ¶
type DefaultBody ¶
type HTTPRequestsUtils ¶
type HTTPRequestsUtils interface {
// Get は指定されたURLにGETリクエストを送信し、HTTPResponseを返します
Get(url string) (*HTTPResponse, error)
// Post は指定されたURLにPOSTリクエストを送信し、HTTPResponseを返します
Post(url string, contentType string, body []byte) (*HTTPResponse, error)
}
HTTPRequestsUtils インターフェースはHTTPリクエストのメソッドを定義します
func NewHTTPRequestsUtils ¶
func NewHTTPRequestsUtils() HTTPRequestsUtils
NewHTTPRequestsUtils は新しい HTTPRequestsUtils インスタンスを作成します
Click to show internal directories.
Click to hide internal directories.