web

package
v0.0.0-...-d991eac Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alive

func Alive(c *gin.Context)

func Broadcast

func Broadcast(senderIP []byte, port int) error

func CreateForward

func CreateForward(c *gin.Context, Host string, IsHttps bool, CAPath string) func(*gin.Context)

func Done

func Done(c *gin.Context, data ...interface{})

func Error

func Error(c *gin.Context, errCode interface{}, err error, netCode ...int)

func GenJWT

func GenJWT(secret, Issuer, UserID, LoginFrom string, ExpireDuration time.Duration) (string, error)

func GetVerTLSConfig

func GetVerTLSConfig(CAPath string) (*tls.Config, error)

func GinJWTCheck

func GinJWTCheck() func(c *gin.Context)

func GinNewRouterInit

func GinNewRouterInit() *gin.Engine

func GinRouterInit

func GinRouterInit() *gin.Engine

func GinRouterWithLogInit

func GinRouterWithLogInit() *gin.Engine

func GinSession

func GinSession(R *gin.Engine, path, domain, secret string, maxAge int) error

func HostReverseProxy

func HostReverseProxy(w http.ResponseWriter, req *http.Request, targetHost *httputil.TargetHost)

func HttpServer

func HttpServer(addr string, handler http.Handler) *http.Server

func InitFirewall

func InitFirewall(Port []string, Forward func(*gin.Context), Wall func() gin.HandlerFunc)

func Logger

func Logger(msgC chan string) gin.HandlerFunc

func MiddleWare

func MiddleWare() gin.HandlerFunc

func NewFormPost

func NewFormPost(target string, data interface{}) (*http.Request, error)

func NewGet

func NewGet(target string) (*http.Request, error)

func NewJsonPost

func NewJsonPost(target string, data interface{}) (*http.Request, error)

func NewReq

func NewReq(method, target string, data ...interface{}) (*http.Request, error)

func PageNotFound

func PageNotFound(c *gin.Context)

func StartHttpServer

func StartHttpServer(addr string, handler http.Handler) error

func StartMultiHttpServer

func StartMultiHttpServer(ServerList ...*http.Server) error

func WebsocketServer

func WebsocketServer(p func(ws *websocket.Conn) error) http.Handler

Types

type LogParams

type LogParams struct {
	// TimeStamp shows the time after the server returns a response.
	TimeStamp time.Time `json:"TimeStamp" bson:"timestamp"`
	// StatusCode is HTTP response code.
	StatusCode int `json:"StatusCode" bson:"statuscode"`
	// Latency is how much time the server cost to process a certain request.
	Latency time.Duration `json:"Latency" bson:"latency"`
	// ClientIP equals Context's ClientIP method.
	ClientIP string `json:"ClientIP" bson:"clientip"`
	// Method is the HTTP method given to the request.
	Method string `json:"Method" bson:"method"`
	// Path is a path the client requests.
	Path string `json:"Path" bson:"path`
	// ErrorMessage is set if error has occurred in processing the request.
	ErrorMessage string `json:"ErrorMessage" bson:"errormessage"`

	// BodySize is the size of the Response Body
	BodySize int `json:"BodySize" bson:"bodysize"`
	// Keys are the keys set on the request's context.
	Keys map[string]interface{} `json:"Keys" bson:"keys"`
}

type PixuClaims

type PixuClaims struct {
	UserID    string `json:"UserID"`
	LoginFrom string `json:"LoginFrom"`
	jwt.RegisteredClaims
}

func ParseJWT

func ParseJWT(secret, RawToken string) (*PixuClaims, error)

type WebsocketHeartbeat

type WebsocketHeartbeat struct {
	Alive string `json:"Alive"`
}

Jump to

Keyboard shortcuts

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