Documentation ¶
Index ¶
- type AdvFrontendUtil
- func (s *AdvFrontendUtil) DefaultForbiddenHandler(ctx *gin.Context)
- func (s *AdvFrontendUtil) DefaultNotFoundHandler(ctx *gin.Context)
- func (s *AdvFrontendUtil) SetForbiddenHandler(fn gin.HandlerFunc)
- func (s *AdvFrontendUtil) SetNotFoundHandler(fn gin.HandlerFunc)
- func (s *AdvFrontendUtil) StaticFilesHandler(ctx *gin.Context)
- func (s *AdvFrontendUtil) VueHistoryModeHandler(ctx *gin.Context)
- type FrontendProxy
- type FrontendUtil
- func (s *FrontendUtil) DefaultForbiddenHandler(ctx *gin.Context)
- func (s *FrontendUtil) DefaultNotFoundHandler(ctx *gin.Context)
- func (s *FrontendUtil) SetForbiddenHandler(fn gin.HandlerFunc)
- func (s *FrontendUtil) SetNotFoundHandler(fn gin.HandlerFunc)
- func (s *FrontendUtil) StaticFilesHandler(ctx *gin.Context)
- func (s *FrontendUtil) VueHistoryModeHandler(ctx *gin.Context)
- type HttpFileWrapper
- type HttpFsWrapper
- type HttpServerConfig
- type IAdvancedFile
- type IAdvancedFilesystem
- type IFilesystem
- type IWebSubServiceLogic
- type OsFsWithPrefix
- type OsFsWrapFromIAdvancedFilesystem
- type WebSubService
- type WebSubServiceContext
- func (c *WebSubServiceContext) DefaultMiddleware(logPrefix, recoveryLogPrefix string)
- func (c *WebSubServiceContext) EnableFrontend(fs IFilesystem, useVueHistoryMode bool) *FrontendUtil
- func (c *WebSubServiceContext) EnableFrontendProxy(proxyURL string) error
- func (c *WebSubServiceContext) EnableFrontendWithAdvancedFs(fs IAdvancedFilesystem, useVueHistoryMode bool) *AdvFrontendUtil
- func (c *WebSubServiceContext) EnableLogger(logPrefix string)
- func (c *WebSubServiceContext) EnableRecovery(recoveryLogPrefix string)
- func (c *WebSubServiceContext) EnableTLS(certFile, keyFile string)
- func (c *WebSubServiceContext) GetEngine() *gin.Engine
- func (c *WebSubServiceContext) GetRootRouter() *gin.RouterGroup
- func (c *WebSubServiceContext) GetSubSvcCtx() *core.SubServiceContext
- func (c *WebSubServiceContext) MakeHttpServer(bindAddr string, config *HttpServerConfig) *http.Server
- func (c *WebSubServiceContext) SetShutdownTimeout(d time.Duration)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdvFrontendUtil ¶ added in v1.2.0
type AdvFrontendUtil struct {
// contains filtered or unexported fields
}
func NewAdvFrontendUtil ¶ added in v1.2.0
func NewAdvFrontendUtil(fs IAdvancedFilesystem, vueHistoryMode bool) *AdvFrontendUtil
func (*AdvFrontendUtil) DefaultForbiddenHandler ¶ added in v1.2.0
func (s *AdvFrontendUtil) DefaultForbiddenHandler(ctx *gin.Context)
func (*AdvFrontendUtil) DefaultNotFoundHandler ¶ added in v1.2.0
func (s *AdvFrontendUtil) DefaultNotFoundHandler(ctx *gin.Context)
func (*AdvFrontendUtil) SetForbiddenHandler ¶ added in v1.2.0
func (s *AdvFrontendUtil) SetForbiddenHandler(fn gin.HandlerFunc)
func (*AdvFrontendUtil) SetNotFoundHandler ¶ added in v1.2.0
func (s *AdvFrontendUtil) SetNotFoundHandler(fn gin.HandlerFunc)
func (*AdvFrontendUtil) StaticFilesHandler ¶ added in v1.2.0
func (s *AdvFrontendUtil) StaticFilesHandler(ctx *gin.Context)
func (*AdvFrontendUtil) VueHistoryModeHandler ¶ added in v1.2.0
func (s *AdvFrontendUtil) VueHistoryModeHandler(ctx *gin.Context)
type FrontendProxy ¶ added in v1.1.0
type FrontendProxy struct {
// contains filtered or unexported fields
}
func NewFrontendProxy ¶ added in v1.1.0
func NewFrontendProxy(proxyURL string) (*FrontendProxy, error)
func (*FrontendProxy) RedirectNotFoundHandler ¶ added in v1.1.0
func (p *FrontendProxy) RedirectNotFoundHandler(context *gin.Context)
type FrontendUtil ¶
type FrontendUtil struct {
// contains filtered or unexported fields
}
func NewFrontendUtil ¶
func NewFrontendUtil(fs IFilesystem, vueHistoryMode bool) *FrontendUtil
func (*FrontendUtil) DefaultForbiddenHandler ¶
func (s *FrontendUtil) DefaultForbiddenHandler(ctx *gin.Context)
func (*FrontendUtil) DefaultNotFoundHandler ¶
func (s *FrontendUtil) DefaultNotFoundHandler(ctx *gin.Context)
func (*FrontendUtil) SetForbiddenHandler ¶
func (s *FrontendUtil) SetForbiddenHandler(fn gin.HandlerFunc)
func (*FrontendUtil) SetNotFoundHandler ¶
func (s *FrontendUtil) SetNotFoundHandler(fn gin.HandlerFunc)
func (*FrontendUtil) StaticFilesHandler ¶
func (s *FrontendUtil) StaticFilesHandler(ctx *gin.Context)
func (*FrontendUtil) VueHistoryModeHandler ¶
func (s *FrontendUtil) VueHistoryModeHandler(ctx *gin.Context)
type HttpFileWrapper ¶ added in v1.2.0
type HttpFileWrapper struct {
// contains filtered or unexported fields
}
func (*HttpFileWrapper) Close ¶ added in v1.2.0
func (h *HttpFileWrapper) Close() error
func (*HttpFileWrapper) Read ¶ added in v1.2.0
func (h *HttpFileWrapper) Read(p []byte) (n int, err error)
func (*HttpFileWrapper) Readdir ¶ added in v1.2.0
func (h *HttpFileWrapper) Readdir(count int) ([]fs.FileInfo, error)
type HttpFsWrapper ¶ added in v1.2.0
type HttpFsWrapper struct {
// contains filtered or unexported fields
}
type HttpServerConfig ¶
type HttpServerConfig struct { // DisableGeneralOptionsHandler, if true, passes "OPTIONS *" requests to the Handler, // otherwise responds with 200 OK and Content-Length: 0. DisableGeneralOptionsHandler bool // TLSConfig optionally provides a TLS configuration for use // by ServeTLS and ListenAndServeTLS. Note that this value is // cloned by ServeTLS and ListenAndServeTLS, so it's not // possible to modify the configuration with methods like // tls.Config.SetSessionTicketKeys. To use // SetSessionTicketKeys, use Server.Serve with a TLS Listener // instead. TLSConfig *tls.Config // ReadTimeout is the maximum duration for reading the entire // request, including the body. A zero or negative value means // there will be no timeout. // // Because ReadTimeout does not let Handlers make per-request // decisions on each request body's acceptable deadline or // upload rate, most users will prefer to use // ReadHeaderTimeout. It is valid to use them both. ReadTimeout time.Duration // ReadHeaderTimeout is the amount of time allowed to read // request headers. The connection's read deadline is reset // after reading the headers and the Handler can decide what // is considered too slow for the body. If ReadHeaderTimeout // is zero, the value of ReadTimeout is used. If both are // zero, there is no timeout. ReadHeaderTimeout time.Duration // WriteTimeout is the maximum duration before timing out // writes of the response. It is reset whenever a new // request's header is read. Like ReadTimeout, it does not // let Handlers make decisions on a per-request basis. // A zero or negative value means there will be no timeout. WriteTimeout time.Duration // IdleTimeout is the maximum amount of time to wait for the // next request when keep-alives are enabled. If IdleTimeout // is zero, the value of ReadTimeout is used. If both are // zero, there is no timeout. IdleTimeout time.Duration // MaxHeaderBytes controls the maximum number of bytes the // server will read parsing the request header's keys and // values, including the request line. It does not limit the // size of the request body. // If zero, DefaultMaxHeaderBytes is used. MaxHeaderBytes int // TLSNextProto optionally specifies a function to take over // ownership of the provided TLS connection when an ALPN // protocol upgrade has occurred. The map key is the protocol // name negotiated. The Handler argument should be used to // handle HTTP requests and will initialize the Request's TLS // and RemoteAddr if not already set. The connection is // automatically closed when the function returns. // If TLSNextProto is not nil, HTTP/2 support is not enabled // automatically. TLSNextProto map[string]func(*http.Server, *tls.Conn, http.Handler) // ConnState specifies an optional callback function that is // called when a client connection changes state. See the // ConnState type and associated constants for details. ConnState func(net.Conn, http.ConnState) // ErrorLog specifies an optional logger for errors accepting // connections, unexpected behavior from handlers, and // underlying FileSystem errors. // If nil, logging is done via the log package's standard logger. ErrorLog *log.Logger // BaseContext optionally specifies a function that returns // the base context for incoming requests on this server. // The provided Listener is the specific Listener that's // about to start accepting requests. // If BaseContext is nil, the default is context.Background(). // If non-nil, it must return a non-nil context. BaseContext func(net.Listener) context.Context // ConnContext optionally specifies a function that modifies // the context used for a new connection c. The provided ctx // is derived from the base context and has a ServerContextKey // value. ConnContext func(ctx context.Context, c net.Conn) context.Context }
type IAdvancedFile ¶ added in v1.2.0
type IAdvancedFilesystem ¶ added in v1.2.0
type IFilesystem ¶
type IWebSubServiceLogic ¶
type IWebSubServiceLogic interface { Prepare(ctx *WebSubServiceContext) error GetHttpServer(ctx *WebSubServiceContext) *http.Server }
type OsFsWithPrefix ¶
type OsFsWithPrefix struct {
// contains filtered or unexported fields
}
func NewOsFsWithPrefix ¶
func NewOsFsWithPrefix(prefix string) *OsFsWithPrefix
type OsFsWrapFromIAdvancedFilesystem ¶ added in v1.2.0
type OsFsWrapFromIAdvancedFilesystem struct {
BaseFs IAdvancedFilesystem
}
type WebSubService ¶
type WebSubService struct {
// contains filtered or unexported fields
}
func NewWebSubService ¶
func NewWebSubService(logic IWebSubServiceLogic) *WebSubService
func (*WebSubService) Prepare ¶
func (w *WebSubService) Prepare(ctx *core.SubServiceContext) error
func (*WebSubService) Run ¶
func (w *WebSubService) Run(ctx *core.SubServiceContext) error
func (*WebSubService) Stop ¶
func (w *WebSubService) Stop(ctx *core.SubServiceContext)
type WebSubServiceContext ¶
type WebSubServiceContext struct { core.IModuleLogger // contains filtered or unexported fields }
func (*WebSubServiceContext) DefaultMiddleware ¶
func (c *WebSubServiceContext) DefaultMiddleware(logPrefix, recoveryLogPrefix string)
DefaultMiddleware will call EnableLogger and EnableRecovery
func (*WebSubServiceContext) EnableFrontend ¶
func (c *WebSubServiceContext) EnableFrontend(fs IFilesystem, useVueHistoryMode bool) *FrontendUtil
func (*WebSubServiceContext) EnableFrontendProxy ¶ added in v1.1.0
func (c *WebSubServiceContext) EnableFrontendProxy(proxyURL string) error
func (*WebSubServiceContext) EnableFrontendWithAdvancedFs ¶ added in v1.2.0
func (c *WebSubServiceContext) EnableFrontendWithAdvancedFs(fs IAdvancedFilesystem, useVueHistoryMode bool) *AdvFrontendUtil
func (*WebSubServiceContext) EnableLogger ¶
func (c *WebSubServiceContext) EnableLogger(logPrefix string)
EnableLogger enable gin logger middleware
func (*WebSubServiceContext) EnableRecovery ¶
func (c *WebSubServiceContext) EnableRecovery(recoveryLogPrefix string)
EnableRecovery enable gin recovery middleware
func (*WebSubServiceContext) EnableTLS ¶
func (c *WebSubServiceContext) EnableTLS(certFile, keyFile string)
EnableTLS if you want to use TLS, please call this from IWebSubServiceLogic.GetHttpServer
func (*WebSubServiceContext) GetEngine ¶
func (c *WebSubServiceContext) GetEngine() *gin.Engine
func (*WebSubServiceContext) GetRootRouter ¶
func (c *WebSubServiceContext) GetRootRouter() *gin.RouterGroup
GetRootRouter get the root RouterGroup of gin engine
func (*WebSubServiceContext) GetSubSvcCtx ¶
func (c *WebSubServiceContext) GetSubSvcCtx() *core.SubServiceContext
GetSubSvcCtx get the SubServiceContext of this sub service
func (*WebSubServiceContext) MakeHttpServer ¶
func (c *WebSubServiceContext) MakeHttpServer(bindAddr string, config *HttpServerConfig) *http.Server
MakeHttpServer create a http.Server for IWebSubServiceLogic.GetHttpServer bindAddr: the address to bind config: the config for http server. refer to http.Server. for basic usage, you can give it nil.
func (*WebSubServiceContext) SetShutdownTimeout ¶
func (c *WebSubServiceContext) SetShutdownTimeout(d time.Duration)
SetShutdownTimeout set the graceful shutdown timeout when stopping server. will force stop server when timeout exceeded.