Documentation ¶
Index ¶
- Constants
- func AddShutdownListener(fn func()) (waitForCalled func())
- func AddWrapUpListener(fn func()) (waitForCalled func())
- func NewConfigEnvCommand(c interface{}) *cobra.Command
- func StartHTTP(host string, port int, handler http.Handler, opts ...StartOption) error
- func StartHTTPS(conf APIConfig, handler http.Handler, opts ...StartOption) error
- type APIConfig
- type AppConfig
- type Server
- type ServerOption
- type StartOption
Constants ¶
View Source
const ( RunModeDebug = "debug" RunModeTest = "test" RunModeDev = "dev" RunModeProd = "prod" RunModeProduction = "production" RunModeRelease = "release" )
Variables ¶
This section is empty.
Functions ¶
func AddShutdownListener ¶
func AddShutdownListener(fn func()) (waitForCalled func())
AddShutdownListener adds fn as a shutdown listener. The returned func can be used to wait for fn getting called.
func AddWrapUpListener ¶
func AddWrapUpListener(fn func()) (waitForCalled func())
AddWrapUpListener adds fn as a wrap up listener. The returned func can be used to wait for fn getting called.
func NewConfigEnvCommand ¶
func StartHTTPS ¶
func StartHTTPS(conf APIConfig, handler http.Handler, opts ...StartOption) error
StartHTTPS starts a https server.
Types ¶
type APIConfig ¶
type AppConfig ¶
type AppConfig struct { ServiceName string `yaml:"service_name" env-default:"gin-project" env-description:"the name of the service"` HostIP string `yaml:"local_ip" env:"HostIP" env-default:"0.0.0.0" env-description:"listening on which IP"` APIPort int `yaml:"api_port" env:"APIPort" env-default:"8000" env-description:"listening on which port"` AdminPort int `yaml:"admin_port" env:"AdminPort" env-default:"8001" env-description:"listening on which port of admin service"` RunMode string `yaml:"run_mode" env:"RunMode" env-description:"run mode of the service"` CertFile string `yaml:"cert_file" env:"CertFile" env-description:"cert file if server need to use tls"` KeyFile string `yaml:"key_file" env:"KeyFile" env-description:"key file if server need to use tls"` }
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func CreateNewServer ¶
func CreateNewServer(ctx context.Context, c APIConfig, opts ...ServerOption) *Server
CreateNewServer create a new server with gin
func (*Server) AddGinGroup ¶
func (s *Server) AddGinGroup(group string) *gin.RouterGroup
func (*Server) StartAdminOnly ¶
func (s *Server) StartAdminOnly()
type ServerOption ¶
type ServerOption func(*serverOptions)
func Migration ¶
func Migration(tables []interface{}) ServerOption
func RawColumn ¶ added in v0.1.0
func RawColumn(raw bool) ServerOption
type StartOption ¶
StartOption defines the method to customize http.Server.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.