Documentation ¶
Index ¶
- func GetClientIP(req *http.Request) (string, error)
- func GetOwnIP() (string, error)
- func UnmarshalBody(req *http.Request, target interface{}) error
- func Write(writer http.ResponseWriter, response *ResponseDTO) error
- func WriteAndLog(ctx context.Context, writer http.ResponseWriter, response *ResponseDTO, ...)
- func WriteErrAndLog(ctx context.Context, writer http.ResponseWriter, err error, log logger.Logger)
- type ResponseBodyDTO
- type ResponseDTO
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetClientIP ¶
GetClientIP extracts the client IP Address from the given HTTP request.
func UnmarshalBody ¶
UnmarshalBody reads the body of the given HTTP request and decodes it into the provided interface.
func Write ¶
func Write(writer http.ResponseWriter, response *ResponseDTO) error
Write writes the provided ResponseDTO as the HTTP response using the provided writer.
func WriteAndLog ¶
func WriteAndLog(ctx context.Context, writer http.ResponseWriter, response *ResponseDTO, log logger.Logger)
WriteAndLog writes the provided ResponseDTO as the HTTP response using the provided writer. If write call fails, it does not return the error. Instead, it logs it using the provided logger.
func WriteErrAndLog ¶
WriteErrAndLog writes the provided error as the HTTP response using the provided writer. If write call fails, it does not return the error. Instead, it logs it using the provided logger.
Types ¶
type ResponseBodyDTO ¶
type ResponseBodyDTO struct { StatusCode int `json:"status_code"` CustomCode string `json:"custom_code"` Data interface{} `json:"data"` Errors []string `json:"errors"` }
ResponseBodyDTO is the schema for all response bodies.
type ResponseDTO ¶
ResponseDTO contains all data that may be required by the router layer to send back a response to the external user.