Documentation ¶
Index ¶
- func WithALPN(enable bool) config.Option
- func WithAltTransport(transporter func(options *config.Options) network.Transporter) config.Option
- func WithAutoReloadRender(b bool, interval time.Duration) config.Option
- func WithBasePath(basePath string) config.Option
- func WithBindConfig(bc *binding.BindConfig) config.Option
- func WithCustomBinder(b binding.Binder) config.Option
- func WithCustomValidator(b binding.StructValidator) config.Option
- func WithDisableHeaderNamesNormalizing(disable bool) config.Option
- func WithDisablePreParseMultipartForm(b bool) config.Option
- func WithDisablePrintRoute(b bool) config.Option
- func WithExitWaitTime(timeout time.Duration) config.Option
- func WithGetOnly(isOnly bool) config.Option
- func WithH2C(enable bool) config.Option
- func WithHandleMethodNotAllowed(b bool) config.Option
- func WithHostPorts(hp string) config.Option
- func WithIdleTimeout(t time.Duration) config.Option
- func WithKeepAlive(b bool) config.Option
- func WithKeepAliveTimeout(t time.Duration) config.Option
- func WithListenConfig(l *net.ListenConfig) config.Option
- func WithMaxKeepBodySize(bs int) config.Option
- func WithMaxRequestBodySize(bs int) config.Option
- func WithNetwork(nw string) config.Option
- func WithOnAccept(fn func(conn net.Conn) context.Context) config.Option
- func WithOnConnect(fn func(ctx context.Context, conn network.Conn) context.Context) config.Option
- func WithReadBufferSize(size int) config.Option
- func WithReadTimeout(t time.Duration) config.Option
- func WithRedirectFixedPath(b bool) config.Option
- func WithRedirectTrailingSlash(b bool) config.Option
- func WithRegistry(r registry.Registry, info *registry.Info) config.Option
- func WithRemoveExtraSlash(b bool) config.Option
- func WithStreamBody(b bool) config.Option
- func WithTLS(cfg *tls.Config) config.Option
- func WithTraceLevel(level stats.Level) config.Option
- func WithTracer(t tracer.Tracer) config.Option
- func WithTransport(transporter func(options *config.Options) network.Transporter) config.Option
- func WithUnescapePathValues(b bool) config.Option
- func WithUseRawPath(b bool) config.Option
- func WithValidateConfig(vc *binding.ValidateConfig) config.Option
- func WithWriteTimeout(t time.Duration) config.Option
- type Hertz
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithAltTransport ¶
WithAltTransport sets which network library to use as an alternative transporter(need to be implemented by specific transporter).
func WithAutoReloadRender ¶
WithAutoReloadRender sets the config of auto reload render. If auto reload render is enabled: 1. interval = 0 means reload render according to file watch mechanism.(recommended) 2. interval > 0 means reload render every interval.
func WithBasePath ¶
WithBasePath sets basePath.Must be "/" prefix and suffix,If not the default concatenate "/"
func WithBindConfig ¶
func WithBindConfig(bc *binding.BindConfig) config.Option
WithBindConfig sets bind config.
func WithCustomBinder ¶
WithCustomBinder sets customized Binder.
func WithCustomValidator ¶
func WithCustomValidator(b binding.StructValidator) config.Option
WithCustomValidator sets customized Binder.
func WithDisableHeaderNamesNormalizing ¶
WithDisableHeaderNamesNormalizing is used to set whether disable header names normalizing.
func WithDisablePreParseMultipartForm ¶
WithDisablePreParseMultipartForm sets disablePreParseMultipartForm.
This option is useful for servers that desire to treat multipart form data as a binary blob, or choose when to parse the data. Server pre parses multipart form data by default.
func WithDisablePrintRoute ¶
WithDisablePrintRoute sets whether disable debugPrintRoute If we don't set it, it will default to false
func WithExitWaitTime ¶
WithExitWaitTime sets timeout for graceful shutdown.
The server may exit ahead after all connections closed. All responses after shutdown will be added 'Connection: close' header.
func WithGetOnly ¶
WithGetOnly sets whether accept GET request only. Default: false
func WithHandleMethodNotAllowed ¶
WithHandleMethodNotAllowed sets handleMethodNotAllowed.
If enabled, the router checks if another method is allowed for the current route, if the current request can not be routed. If this is the case, the request is answered with 'Method Not Allowed' and HTTP status code 405. If no other Method is allowed, the request is delegated to the NotFound handler.
func WithHostPorts ¶
WithHostPorts sets listening address.
func WithIdleTimeout ¶
WithIdleTimeout sets idle timeout.
Close the connection when the successive request timeout (in keepalive mode). Set this to protect server from misbehavior clients.
func WithKeepAlive ¶
WithKeepAlive sets Whether use long connection. Default: true
func WithKeepAliveTimeout ¶
WithKeepAliveTimeout sets keep-alive timeout.
In most cases, there is no need to care about this option.
func WithListenConfig ¶
func WithListenConfig(l *net.ListenConfig) config.Option
WithListenConfig sets listener config.
func WithMaxKeepBodySize ¶
WithMaxKeepBodySize sets max size of request/response body to keep when recycled. Unit: byte
Body buffer which larger than this size will be put back into buffer poll.
func WithMaxRequestBodySize ¶
WithMaxRequestBodySize sets the limitation of request body size. Unit: byte
Body buffer which larger than this size will be put back into buffer poll.
func WithNetwork ¶
WithNetwork sets network. Support "tcp", "udp", "unix"(unix domain socket).
func WithOnAccept ¶
WithOnAccept sets the callback function when a new connection is accepted but cannot receive data in netpoll. In go net, it will be called before converting tls connection
func WithOnConnect ¶
WithOnConnect sets the onConnect function. It can received data from connection in netpoll. In go net, it will be called after converting tls connection.
func WithReadBufferSize ¶
WithReadBufferSize sets the read buffer size which also limit the header size.
func WithReadTimeout ¶
WithReadTimeout sets read timeout.
Close the connection when read request timeout.
func WithRedirectFixedPath ¶
WithRedirectFixedPath sets redirectFixedPath.
If enabled, the router tries to fix the current request path, if no handle is registered for it. First superfluous path elements like ../ or // are removed. Afterwards the router does a case-insensitive lookup of the cleaned path. If a handle can be found for this route, the router makes a redirection to the corrected path with status code 301 for GET requests and 308 for all other request methods. For example /FOO and /..//Foo could be redirected to /foo. RedirectTrailingSlash is independent of this option.
func WithRedirectTrailingSlash ¶
WithRedirectTrailingSlash sets redirectTrailingSlash.
Enables automatic redirection if the current route can't be matched but a handler for the path with (without) the trailing slash exists. For example if /foo/ is requested but a route only exists for /foo, the client is redirected to /foo with http status code 301 for GET requests and 307 for all other request methods.
func WithRegistry ¶
WithRegistry sets the registry and registry's info
func WithRemoveExtraSlash ¶
WithRemoveExtraSlash sets removeExtraSlash.
RemoveExtraSlash a parameter can be parsed from the URL even with extra slashes. If UseRawPath is false (by default), the RemoveExtraSlash effectively is true, as url.Path gonna be used, which is already cleaned.
func WithStreamBody ¶
WithStreamBody determines whether read body in stream or not.
StreamRequestBody enables streaming request body, and calls the handler sooner when given body is larger than the current limit.
func WithTLS ¶
WithTLS sets TLS config to start a tls server.
NOTE: If a tls server is started, it won't accept non-tls request.
func WithTraceLevel ¶
WithTraceLevel sets the level trace.
func WithTransport ¶
WithTransport sets which network library to use.
func WithUnescapePathValues ¶
WithUnescapePathValues sets unescapePathValues.
If true, the path value will be unescaped. If UseRawPath is false (by default), the UnescapePathValues effectively is true, as url.Path gonna be used, which is already unescaped.
func WithUseRawPath ¶
WithUseRawPath sets useRawPath.
If enabled, the url.RawPath will be used to find parameters.
func WithValidateConfig ¶
func WithValidateConfig(vc *binding.ValidateConfig) config.Option
WithValidateConfig sets validate config.
Types ¶
type Hertz ¶
Hertz is the core struct of hertz.
func (*Hertz) SetCustomSignalWaiter ¶
SetCustomSignalWaiter sets the signal waiter function. If Default one is not met the requirement, set this function to customize. Hertz will exit immediately if f returns an error, otherwise it will exit gracefully.