app_base

package
v0.0.0-...-c954acd Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReasonServerError    = "ServerError"
	ReasonInvalidRequest = "InvalidRequest"
)

Variables

This section is empty.

Functions

func ShouldBindJSON

func ShouldBindJSON(c *gin.Context, i interface{}) error

func ShouldBindQuery

func ShouldBindQuery(c *gin.Context, i interface{}) error

Types

type BaseApp

type BaseApp struct {
	Version string

	Addr                string
	Name                string
	TelegramAdminChatID string

	Bot    *tb.Bot
	Router *gin.Engine
}

func SetupBaseApp

func SetupBaseApp(options BaseOptions) BaseApp

func (*BaseApp) E

func (app *BaseApp) E(statusCode int, reason string, description interface{}) *Err

func (*BaseApp) HandleError

func (app *BaseApp) HandleError(c *gin.Context, err error)

HandleError handlers errors in a general way

func (*BaseApp) HandlerHealthz

func (app *BaseApp) HandlerHealthz(c *gin.Context)

HandlerHealthz is the health check handler

func (*BaseApp) HandlerIndex

func (app *BaseApp) HandlerIndex(c *gin.Context)

HandlerIndex is the default handler

func (*BaseApp) HandlerSend

func (app *BaseApp) HandlerSend(c *gin.Context)

HandlerSend sends a message to a single chat

func (*BaseApp) MustBindJSON

func (app *BaseApp) MustBindJSON(c *gin.Context, i interface{}) bool

MustBindJSON used to bind query data to structure, returns false when failed, and response is written automatically

func (*BaseApp) MustBindQuery

func (app *BaseApp) MustBindQuery(c *gin.Context, i interface{}) bool

MustBindQuery used to bind query data to structure, returns false when failed, and response is written automatically

func (*BaseApp) Send

func (app *BaseApp) Send(to tb.Recipient, what interface{}, options ...interface{})

func (*BaseApp) Serve

func (app *BaseApp) Serve() error

type BaseOptions

type BaseOptions struct {
	Version string

	Addr                string
	Name                string
	TelegramBotToken    string
	TelegramAdminChatID string
}

type Detail

type Detail struct {
	Message interface{} `json:"message"`
}

type Err

type Err struct {
	StatusCode  int         `json:"status_code"`
	Reason      string      `json:"reason"`
	Description interface{} `json:"description"` // usually a string
	Details     []Detail    `json:"details,omitempty"`
}

func E

func E(statusCode int, reason string, description interface{}) *Err

E builds a new *Err from parameters

func (*Err) Error

func (e *Err) Error() string

Jump to

Keyboard shortcuts

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