Documentation ¶
Index ¶
- Constants
- func ConnectToDatabase(ctx context.Context, params *DatabaseConnectionParams, log *zap.Logger, ...) (*core_database.DatabaseConn, error)
- func CreateRequestBody(body interface{}) (*bytes.Reader, error)
- func DecodeJSONBody(w http.ResponseWriter, r *http.Request, dst interface{}) error
- func ErrorResponse(w http.ResponseWriter, error string, code int)
- func ExtractIDFromRequest(r *http.Request) (uint64, error)
- func ExtractStripeConnectedAccountIdFromRequest(r *http.Request) (string, error)
- func GenerateRandomString(n int) string
- func IsEmpty(field string) bool
- func JSONResponse(w http.ResponseWriter, result interface{})
- func JSONResponseCode(w http.ResponseWriter, result interface{}, responseCode int)
- type DatabaseConnectionParams
- type MalformedRequest
Constants ¶
View Source
const BADLY_FORMATTED_JSON string = "Request body contains badly-formed JSON"
View Source
const (
EMPTY = ""
)
View Source
const MAX_REQUEST_READ_SIZE int64 = 1048576
View Source
const REQUEST_BODY_MUST_NOT_BE_EMPTY string = "Request body must not be empty"
View Source
const RESPONSE_BODY_MUST_NOT_BE_LARGER_THAN_1MB string = "Request body must not be larger than 1MB"
Variables ¶
This section is empty.
Functions ¶
func ConnectToDatabase ¶
func ConnectToDatabase(ctx context.Context, params *DatabaseConnectionParams, log *zap.Logger, models ...interface{}) (*core_database.DatabaseConn, error)
ConnectToDatabase establish and connects to a database instance
func CreateRequestBody ¶
CreateRequestBody creates a request object to be used in an http call
func DecodeJSONBody ¶
func DecodeJSONBody(w http.ResponseWriter, r *http.Request, dst interface{}) error
DecodeJSONBody decodes a request body in json form and returns a malformed request error type if any errors do occur
func ErrorResponse ¶
func ErrorResponse(w http.ResponseWriter, error string, code int)
func ExtractIDFromRequest ¶
ExtractIDFromRequest takes as input a request object and extracts an id from it
func ExtractStripeConnectedAccountIdFromRequest ¶
ExtractStripeConnectedAccountIdFromRequest extracts a stripe connected account Id from a connected object
func GenerateRandomString ¶
GenerateRandomString generates a random string based on the size specified by the client
func JSONResponse ¶
func JSONResponse(w http.ResponseWriter, result interface{})
func JSONResponseCode ¶
func JSONResponseCode(w http.ResponseWriter, result interface{}, responseCode int)
Types ¶
type MalformedRequest ¶
MalformedRequest is a custom error type
func (*MalformedRequest) Error ¶
func (mr *MalformedRequest) Error() string
Click to show internal directories.
Click to hide internal directories.