server

package
v0.0.0-...-f6ca644 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Route variable
	Route *gin.Engine
	// ListenConfig variable
	ListenConfig ListenConf
	// ListenSslConfig variable
	ListenSslConfig ListenSslConf
	// Mode variable
	Mode ModeConfg
)
View Source
var DefaultResourceName = ""

DefaultResourceName variable

View Source
var PrivateKey = make(map[string]interface{})

PrivateKey variable

View Source
var PublicKey = make(map[string]interface{})

PublicKey variable

Functions

func CorsHandler

func CorsHandler() gin.HandlerFunc

CorsHandler function

func DefaultHeader

func DefaultHeader() gin.HandlerFunc

DefaultHeader function

func Error

func Error(c *gin.Context, code string, message string, t ...string) gin.H

Error function

func ErrorResponse

func ErrorResponse(code string, message string) gin.H

ErrorResponse function

func GetSessionStore

func GetSessionStore(option SessionOption) sessions.Store

GetSessionStore function

func GinReUnmarshal

func GinReUnmarshal(i interface{}) (gin.H, error)

GinReUnmarshal function

func GinUnmarshal

func GinUnmarshal(r io.Reader) (gin.H, error)

GinUnmarshal function

func LoadDefaultLifecycle

func LoadDefaultLifecycle()

LoadDefaultLifecycle is enable lifecycle liveness and readiness probe

func LoadServer

func LoadServer()

LoadServer function

func LoadSession

func LoadSession(resourceName string) gin.HandlerFunc

LoadSession function

func NewSvcLifecycle

func NewSvcLifecycle() *svcLifecycle

func NotFoundResponse

func NotFoundResponse(c *gin.Context)

NotFoundResponse function

func PairValues

func PairValues(i, o interface{}) error

PairValues function

func ParseRequest

func ParseRequest(c *gin.Context, request interface{}) error

ParseRequest function

func ResponseJSON

func ResponseJSON(c *gin.Context, code int, obj interface{})

ResponseJSON function

func Run

func Run(engine http.Handler, addr ...string)

Run function

func RunAutoCert

func RunAutoCert(r http.Handler, domain ...string) error

RunAutoCert support 1-line LetsEncrypt HTTPS servers

func RunTLS

func RunTLS(addr string, engine http.Handler, certFile, keyFile string)

RunTLS function

func RunWithManager

func RunWithManager(r http.Handler, m *autocert.Manager)

RunWithManager support custom autocert manager

func Session

func Session(c *gin.Context) sessions.Session

Session function

func Start

func Start()

Start function

func StartX

func StartX()

StartX function

Types

type Config

type Config *config.Config

Config type config

type CorsConf

type CorsConf struct {
	CorsOptions CorsOptions `json:"cors" bson:"cors"`
}

CorsConf struct

var Cors CorsConf

Cors variable

type CorsOptions

type CorsOptions struct {
	UseSetting       bool     `json:"useSetting" bson:"useSetting"`
	AllowAllOrigins  bool     `json:"allowAllOrigins" bson:"allowAllOrigins"`
	AllowOrigins     []string `json:"allowOrigins" bson:"allowOrigins"`
	AllowMethods     []string `json:"allowMethods" bson:"allowMethods"`
	AllowHeaders     []string `json:"allowHeaders" bson:"allowHeaders"`
	AllowCredentials bool     `json:"allowCredentials" bson:"allowCredentials"`
	ExposeHeaders    []string `json:"exposeHeaders" bson:"exposeHeaders"`
	AllowWildcard    bool     `json:"allowWildcard" bson:"allowWildcard"`
	MaxAgeSec        int      `json:"maxAgeSec" bson:"maxAgeSec"`
}

CorsOptions is option of cors that defined from config

type JwtConf

type JwtConf struct {
	JwtOptions []JwtOption `json:"jwtResources" bson:"jwtResources"`
}

JwtConf struct

var (
	// Secret variable
	Secret JwtConf
)

type JwtOption

type JwtOption struct {
	Name          string `json:"name" bson:"name"`
	Secret        string `json:"secret" bson:"secret"`
	Algorithm     string `json:"algorithm" bson:"algorithm"`
	ExpirationSec int    `json:"expiration" bson:"expiration"`
	PrivateKey    string `json:"privateKey" bson:"privateKey"`
	PublicKey     string `json:"publicKey" bson:"publicKey"`
}

JwtOption struct

func GetJwtOption

func GetJwtOption(resourceName string) JwtOption

GetJwtOption function

type Listen

type Listen struct {
	ListenAddr string `json:"listenAddr" bson:"listenAddr"`
	ListenPort string `json:"listenPort" bson:"listenPort"`
	Ssl        bool   `json:"ssl" bson:"ssl"`
}

Listen struct

type ListenConf

type ListenConf struct {
	Listen Listen `json:"listen" bson:"listen"`
}

ListenConf struct

type ListenSsl

type ListenSsl struct {
	AutoTls    bool     `json:"autotls" bson:"autotls"`
	Domain     []string `json:"domain" bson:"domain"`
	ListenAddr string   `json:"listenAddr" bson:"listenAddr"`
	ListenPort string   `json:"listenPort" bson:"listenPort"`
	CertFile   string   `json:"certFile" bson:"certFile"`
	KeyFile    string   `json:"keyFile" bson:"keyFile"`
	SslOnly    bool     `json:"sslOnly" bson:"sslOnly"`
}

ListenSsl struct

type ListenSslConf

type ListenSslConf struct {
	ListenSsl ListenSsl `json:"ssl" bson:"ssl"`
}

ListenSslConf struct

type Map

type Map map[string]interface{}

Map type

type ModeConfg

type ModeConfg struct {
	Mode string `json:"mode" bson:"mode"`
}

ModeConfg struct

type SessionConf

type SessionConf struct {
	SessionOption []SessionOption `json:"sessionResources" bson:"sessionResources"`
}

SessionConf struct

var (
	// Sess variable
	Sess SessionConf
)

type SessionOption

type SessionOption struct {
	Name          string `json:"name" bson:"name"`
	Type          string `json:"type" bson:"type"`
	Host          string `json:"host" bson:"host"`
	Secret        string `json:"secret" bson:"secret"`
	Password      string `json:"password" bson:"password"`
	ExpirationSec int    `json:"expiration" bson:"expiration"`
	SessionName   string `json:"sessionName" bson:"sessionName"`
}

SessionOption struct

func GetSessionResource

func GetSessionResource(resourceName string) SessionOption

GetSessionResource function

Jump to

Keyboard shortcuts

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