ginruntime

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GET = iota
	POST
	PUT
	PATCH
	DELETE
)

Exporting constants to avoid hardcoding these all over, and ending up with a uppercase "POST" bug in the future.

Variables

This section is empty.

Functions

func ErrorHandler

func ErrorHandler() gin.HandlerFunc

Types

type ApiError

type ApiError struct {
	Status int
	Reason string
	Detail error
}

Server response status code and associated error message

func BadRequest added in v0.3.0

func BadRequest(reason string) *ApiError

func FailedDependency added in v0.3.0

func FailedDependency(reason string) *ApiError

func Forbidden added in v0.3.0

func Forbidden(reason string) *ApiError

func InternalServerError added in v0.3.0

func InternalServerError(reason string) *ApiError

func Normalize added in v0.3.0

func Normalize(err error) *ApiError

Converts `err` to an `*ApiError` if it's not nil.

func NotFound added in v0.3.0

func NotFound(reason string) *ApiError

func NotImplemented added in v0.3.0

func NotImplemented(reason string) *ApiError

func Unauthorized added in v0.3.0

func Unauthorized(reason string) *ApiError

func UnprocessableEntity added in v0.3.0

func UnprocessableEntity(reason string) *ApiError

func (*ApiError) Error

func (this *ApiError) Error() string

type GinEngine

type GinEngine struct {
	// contains filtered or unexported fields
}

func NewGinEngine

func NewGinEngine() *GinEngine

func (*GinEngine) AddRoute

func (e *GinEngine) AddRoute(group *gin.RouterGroup, path string, method int, handlers ...gin.HandlerFunc)

AddRoute Add a new endpoint mapping

func (*GinEngine) NewGroup

func (e *GinEngine) NewGroup(path string, handlers ...gin.HandlerFunc) *gin.RouterGroup

func (*GinEngine) ServerHttp

func (e *GinEngine) ServerHttp(recorder *httptest.ResponseRecorder, request *http.Request)

Used for unit testing

func (*GinEngine) StartServer

func (e *GinEngine) StartServer(ctx context.Context, tracing bool)

func (*GinEngine) Use added in v0.2.7

func (e *GinEngine) Use(middleware ...gin.HandlerFunc)

Adds middleware

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL