server

package
v0.0.0-...-36cc0b3 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadRequest          = MakeErr(http.StatusBadRequest, 1, "bad request")
	ErrNotFound            = MakeErr(http.StatusNotFound, 2, "not found")
	ErrUnauthorized        = MakeErr(http.StatusUnauthorized, 3, "unauthorized")
	ErrForbidden           = MakeErr(http.StatusForbidden, 4, "forbidden")
	ErrConflict            = MakeErr(http.StatusConflict, 5, "conflict")
	ErrInternalServerError = MakeErr(http.StatusInternalServerError, 6, "internal server error")
)

Functions

func New

func New(registrar ServiceRegistrar) (err error)

func RouteHome

func RouteHome(ctx *gin.Context)

func RouteNotFound

func RouteNotFound(ctx *gin.Context)

Types

type EndpointsRegistrar

type EndpointsRegistrar func(e *gin.Engine)

type Err

type Err struct {
	Error struct {
		Code     int16     `json:"code"`
		Message  string    `json:"message"`
		DateTime time.Time `json:"datetime" format:"date-time"`
	} `json:"error"`
	// contains filtered or unexported fields
}

func MakeErr

func MakeErr(status, code int16, message string) *Err

func (*Err) Send

func (r *Err) Send(ctx *gin.Context)

type Gin

type Gin struct {
	*gin.Engine
}

func NewGin

func NewGin(debugEnabled, logHTTPRequests bool) (engine *Gin)

type OK

type OK struct {
	Data interface{} `json:"data"`
	// contains filtered or unexported fields
}

func MakeOK

func MakeOK(status int16, data interface{}) *OK

func (*OK) Send

func (r *OK) Send(ctx *gin.Context)

type OKSet

type OKSet struct {
	Data interface{} `json:"data"`
	Meta meta        `json:"meta"`
	// contains filtered or unexported fields
}

func MakeOKSet

func MakeOKSet(status int16, data interface{}, offset int, limit int, count int) *OKSet

func (*OKSet) Send

func (r *OKSet) Send(ctx *gin.Context)

type ResponseSenderInterface

type ResponseSenderInterface interface {
	Send(ctx *gin.Context)
}

type Server

type Server struct {
	*http.Server
	// contains filtered or unexported fields
}

type ServiceRegistrar

type ServiceRegistrar interface {
	Register(e *gin.Engine)
	Middlewares() []gin.HandlerFunc
	Address() string
	DebugEnabled() bool
	LogHTTPRequests() bool
}

Jump to

Keyboard shortcuts

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