Documentation
¶
Index ¶
- Constants
- func DefaultAuthMiddleware(next http.Handler, config *config.Config, options map[string]interface{}) http.Handler
- func GetClientIpAddress(r *http.Request) string
- func IsArray(data []byte) bool
- func NewGenericError(tag string, code string, status int, msg string) *genericError
- func NewRouter(config *config.Config, pathPrefix string, routes []Route, ...) *mux.Router
- func ParseJSONBody(body io.Reader, obj interface{}) error
- func ParseJSONBytes(body []byte, obj interface{}) error
- func SendErrorResponse(res http.ResponseWriter, err error)
- func SendJSONResponse(res http.ResponseWriter, body interface{})
- func ValidateStruct(obj interface{}) error
- type AuthInfo
- type AuthMiddlewareFunc
- type BaseService
- type DuplicateRecordError
- type Env
- type Error
- type ForbiddenError
- type InternalError
- type InvalidParameterError
- type InvalidRequestError
- type MissingRequiredParameterError
- type RecordNotFoundError
- type Route
- type RouteHandler
- type Service
- type TokenExpiredError
- type TooManyRequestsError
- type UnauthorizedError
- type UnknownOriginError
Constants ¶
View Source
const ( ErrorDuplicateRecord = "duplicate_record" ErrorForbidden = "forbidden" ErrorInternalError = "internal_error" ErrorInvalidRequest = "invalid_request" ErrorInvalidParameter = "invalid_parameter" ErrorMissingRequiredParameter = "missing_required_parameter" ErrorNotFound = "not_found" ErrorTokenExpired = "token_expired" ErrorTooManyRequests = "too_many_requests" ErrorUnknownOrigin = "unknown_origin" )
View Source
const (
EnableSessionAuthKey = "EnableSessionAuth"
)
View Source
const FirebasePublicKeyUrl = "https://www.googleapis.com/robot/v1/metadata/x509/securetoken@system.gserviceaccount.com"
Variables ¶
This section is empty.
Functions ¶
func DefaultAuthMiddleware ¶ added in v0.9.0
func GetClientIpAddress ¶
func NewGenericError ¶
func NewRouter ¶
func NewRouter(config *config.Config, pathPrefix string, routes []Route, authMiddleware AuthMiddlewareFunc, additionalMiddlewares ...mux.MiddlewareFunc) *mux.Router
func ParseJSONBody ¶
func ParseJSONBytes ¶
func SendErrorResponse ¶
func SendErrorResponse(res http.ResponseWriter, err error)
SendErrorResponse sends a JSON error response with the given error
func SendJSONResponse ¶
func SendJSONResponse(res http.ResponseWriter, body interface{})
SendJSONResponse sends a JSON response with the given body
func ValidateStruct ¶
func ValidateStruct(obj interface{}) error
Types ¶
type AuthInfo ¶ added in v0.7.0
func GetAuthInfoFromRequestContext ¶ added in v0.7.0
GetAuthInfoFromRequestContext returns the AuthInfo object from the given context
type AuthMiddlewareFunc ¶ added in v0.9.0
type BaseService ¶
type BaseService struct {
// contains filtered or unexported fields
}
func NewBaseService ¶
func NewBaseService(env Env) BaseService
func (BaseService) Env ¶
func (svc BaseService) Env() Env
type DuplicateRecordError ¶
type DuplicateRecordError struct {
Type string `json:"type"`
Key interface{} `json:"key"`
// contains filtered or unexported fields
}
DuplicateRecordError type
func NewDuplicateRecordError ¶
func NewDuplicateRecordError(recordType string, recordKey interface{}, reason string) *DuplicateRecordError
type ForbiddenError ¶
type ForbiddenError struct {
// contains filtered or unexported fields
}
ForbiddenError type
func NewForbiddenError ¶
func NewForbiddenError(msg string) *ForbiddenError
type InternalError ¶
type InternalError struct {
// contains filtered or unexported fields
}
InternalError type
func NewInternalError ¶
func NewInternalError(msg string) *InternalError
type InvalidParameterError ¶
type InvalidParameterError struct {
Parameter string `json:"parameter"`
// contains filtered or unexported fields
}
InvalidParameterError type
func NewInvalidParameterError ¶
func NewInvalidParameterError(paramName string, msg string) *InvalidParameterError
func (*InvalidParameterError) Error ¶
func (err *InvalidParameterError) Error() string
type InvalidRequestError ¶
type InvalidRequestError struct {
// contains filtered or unexported fields
}
InvalidRequestError type
func NewInvalidRequestError ¶
func NewInvalidRequestError(msg string) *InvalidRequestError
type MissingRequiredParameterError ¶
type MissingRequiredParameterError struct {
Parameter string `json:"parameter"`
// contains filtered or unexported fields
}
MissingRequiredParameterError type
func NewMissingRequiredParameterError ¶
func NewMissingRequiredParameterError(parameterName string) *MissingRequiredParameterError
func (MissingRequiredParameterError) Error ¶
func (err MissingRequiredParameterError) Error() string
type RecordNotFoundError ¶
type RecordNotFoundError struct {
Type string `json:"type"`
Key interface{} `json:"key"`
// contains filtered or unexported fields
}
RecordNotFoundError type
func NewRecordNotFoundError ¶
func NewRecordNotFoundError(recordType string, recordKey interface{}) *RecordNotFoundError
type RouteHandler ¶
type RouteHandler[T Service] struct { // contains filtered or unexported fields }
func NewRouteHandler ¶
func NewRouteHandler[T Service](svc T, handler func(svc T, w http.ResponseWriter, r *http.Request) error) RouteHandler[T]
func (RouteHandler[T]) ServeHTTP ¶
func (rh RouteHandler[T]) ServeHTTP(w http.ResponseWriter, r *http.Request)
type TokenExpiredError ¶
type TokenExpiredError struct {
// contains filtered or unexported fields
}
TokenExpiredError type
func NewTokenExpiredError ¶
func NewTokenExpiredError() *TokenExpiredError
type TooManyRequestsError ¶
type TooManyRequestsError struct {
// contains filtered or unexported fields
}
TooManyRequestsError type
func NewTooManyRequestsError ¶
func NewTooManyRequestsError() *TooManyRequestsError
type UnauthorizedError ¶
type UnauthorizedError struct {
// contains filtered or unexported fields
}
UnauthorizedError type
func NewUnauthorizedError ¶
func NewUnauthorizedError(msg string) *UnauthorizedError
type UnknownOriginError ¶
type UnknownOriginError struct {
// contains filtered or unexported fields
}
UnknownOriginError type
func NewUnknownOriginError ¶
func NewUnknownOriginError(origin string) *UnknownOriginError
Click to show internal directories.
Click to hide internal directories.