API Reference
Zinc
The core package that provides the foundation for creating and configuring applications.
New #
Creates a new instance of the Zinc application.
func New(config ...Config) *App
// Create a new Zinc app with default configuration
app := zinc.New()
// ...
Config #
The Config struct holds the server configuration parameters. You can modify the default configuration
through methods on the App as you invoke the New()
function.
// Create a new Zinc app with custom configuration
app := zinc.New(zinc.Config{
AppName: "MyZincApp",
AppVersion: "1.0.0",
DefaultAddr: "127.0.0.1:8080",
CaseSensitive: true,
StrictRouting: true,
ReadTimeout: 10 * time.Second,
BodyLimit: 1024 * 1024, // 1MB
EnablePrintRoutes: true,
})
// ...
Configuration Properties #
Property | Type | Description | Default |
---|---|---|---|
AppName | string | Specifies the name of the application. | "" |
AppVersion | string | Specifies the version of the application. | "1.0.0" |
DefaultAddr | string | Specifies the HTTP server address. | "0.0.0.0:6530" |
ServerHeader | string | Sets the value of the Server HTTP header. | "Zinc" |
ShutdownTimeout | time.Duration | Maximum duration to wait for server shutdown. | 10s |
ReadTimeout | time.Duration | Maximum duration for reading the entire request. | 5s |
WriteTimeout | time.Duration | Maximum duration before timing out writes of the response. | 10s |
IdleTimeout | time.Duration | Maximum amount of time to wait for the next request. | 120s |
CaseSensitive | bool | Determines if routes should be case-sensitive. When false, /Foo and /foo are treated as the same route. | false |
StrictRouting | bool | Determines if routes with trailing slashes are different than those without. When false, /api and /api/ are treated as the same route. | false |
BodyLimit | int64 | Sets the maximum allowed size for a request body in bytes. | 4MB |
Concurrency | int | Sets the maximum number of concurrent connections. | 256K |
EnableTrustedProxyCheck | bool | Enables checking for trusted proxies when determining client IP addresses. | false |
TrustedProxies | []string | List of IP addresses or CIDR blocks that are trusted. | [] |
ProxyHeader | string | Specifies which header to use for client IP address. | "X-Forwarded-For" |
DisableKeepalive | bool | Disables keep-alive connections. | false |
DisableDefaultContentType | bool | Disables sending the Content-Type header in responses when no content type is explicitly set. | false |
RouteCacheSize | int | Determines how many routes are stored in the route cache. Set to 0 to disable caching. | 1000 |
DisableStartupMessage | bool | Disables the startup message when the server starts. | false |
EnablePrintRoutes | bool | Enables printing all routes on startup. | false |