gkit

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2022 License: MIT Imports: 14 Imported by: 0

README

Call your code from another module

  1. From the command prompt in the app directory, run the following command:
go mod edit -replace github.com/thienhaole92/chat/common =../common
  1. From the command prompt in the app directory, run the go mod tidy command to synchronize the github.com/thienhaole92/chat/common module's dependencies, adding those required by the code, but not yet tracked in the module.
go mod tidy

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidParam = errors.New("invalid parameter")
	ErrServer       = errors.New("server error")
	ErrUnauthorized = errors.New("unauthorized")
)
View Source
var (
	JWTAuthHeader = "Authorization"
	JaegerHeader  = "Trace-Id"
)

Functions

func ConstructKey

func ConstructKey(prefix, key string) string

func CorsMiddleware

func CorsMiddleware() gin.HandlerFunc

func ExtractTokenFromHeader

func ExtractTokenFromHeader(r *http.Request) string

func GetPageNumber

func GetPageNumber(page string) int

func GetServerAddrs

func GetServerAddrs(addrs string) []string

func InitLogger

func InitLogger(mode string)

func Join

func Join(strs ...string) string

func LoggingMiddleware

func LoggingMiddleware(logger HttpLogger) gin.HandlerFunc

func MaxAllowed

func MaxAllowed(n int64) gin.HandlerFunc

Types

type Closer

type Closer interface {
	Close() error
}

type ErrResponse

type ErrResponse struct {
	Success bool   `json:"success" example:"true"`
	Error   string `json:"error"`
}

type GrpcServer

type GrpcServer interface {
	Register()
	Run()
	GracefulStop()
}

type HttpLogger

type HttpLogger struct {
	*log.Entry
}

func NewHttpLogger

func NewHttpLogger() HttpLogger

type HttpServer

type HttpServer interface {
	RegisterRoutes()
	Run()
	GracefulShutdown(ctx context.Context) error
}

type IDGenerator

type IDGenerator interface {
	NextID() (uint64, error)
}

func NewIDGenerator

func NewIDGenerator() (IDGenerator, error)

type Pagination

type Pagination struct {
	Total int `json:"total"`
	Limit int `json:"limit"`
}

type Runner

type Runner interface {
	Run()
	GracefulShutdown(ctx context.Context) error
}

type Server

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

func NewServer

func NewServer(name string, runner Runner, closer Closer) *Server

func (*Server) GracefulShutdown

func (s *Server) GracefulShutdown(ctx context.Context, done chan bool)

func (*Server) Serve

func (s *Server) Serve()

type SuccessPagingResponse

type SuccessPagingResponse[T any] struct {
	Success    bool       `json:"success" example:"true"`
	Data       T          `json:"data"`
	Pagination Pagination `json:"pagination"`
}

type SuccessResponse

type SuccessResponse[T any] struct {
	Success bool `json:"success" example:"true"`
	Data    T    `json:"data"`
}

Jump to

Keyboard shortcuts

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