美文网首页
iris-配置项

iris-配置项

作者: EasyNetCN | 来源:发表于2020-02-11 22:37 被阅读0次

以下内容摘自源代码configuration.go

// Configuration the whole configuration for an iris instance
// these can be passed via options also, look at the top of this file(configuration.go).
// Configuration is a valid OptionSetter.
type Configuration struct {
    // vhost is private and set only with .Run method, it cannot be changed after the first set.
    // It can be retrieved by the context if needed (i.e router for subdomains)
    vhost string

    // Tunneling can be optionally set to enable ngrok http(s) tunneling for this Iris app instance.
    // See the `WithTunneling` Configurator too.
    Tunneling TunnelingConfiguration `json:"tunneling,omitempty" yaml:"Tunneling" toml:"Tunneling"`

    // IgnoreServerErrors will cause to ignore the matched "errors"
    // from the main application's `Run` function.
    // This is a slice of string, not a slice of error
    // users can register these errors using yaml or toml configuration file
    // like the rest of the configuration fields.
    //
    // See `WithoutServerError(...)` function too.
    //
    // Example: https://github.com/kataras/iris/tree/master/_examples/http-listening/listen-addr/omit-server-errors
    //
    // Defaults to an empty slice.
    IgnoreServerErrors []string `json:"ignoreServerErrors,omitempty" yaml:"IgnoreServerErrors" toml:"IgnoreServerErrors"`

    // DisableStartupLog if set to true then it turns off the write banner on server startup.
    //
    // Defaults to false.
    DisableStartupLog bool `json:"disableStartupLog,omitempty" yaml:"DisableStartupLog" toml:"DisableStartupLog"`
    // DisableInterruptHandler if set to true then it disables the automatic graceful server shutdown
    // when control/cmd+C pressed.
    // Turn this to true if you're planning to handle this by your own via a custom host.Task.
    //
    // Defaults to false.
    DisableInterruptHandler bool `json:"disableInterruptHandler,omitempty" yaml:"DisableInterruptHandler" toml:"DisableInterruptHandler"`

    // DisablePathCorrection corrects and redirects or executes directly the handler of
    // the requested path to the registered path
    // for example, if /home/ path is requested but no handler for this Route found,
    // then the Router checks if /home handler exists, if yes,
    // (permanent)redirects the client to the correct path /home.
    //
    // See `DisablePathCorrectionRedirection` to enable direct handler execution instead of redirection.
    //
    // Defaults to false.
    DisablePathCorrection bool `json:"disablePathCorrection,omitempty" yaml:"DisablePathCorrection" toml:"DisablePathCorrection"`

    // DisablePathCorrectionRedirection works whenever configuration.DisablePathCorrection is set to false
    // and if DisablePathCorrectionRedirection set to true then it will fire the handler of the matching route without
    // the trailing slash ("/") instead of send a redirection status.
    //
    // Defaults to false.
    DisablePathCorrectionRedirection bool `json:"disablePathCorrectionRedirection,omitempty" yaml:"DisablePathCorrectionRedirection" toml:"DisablePathCorrectionRedirection"`

    // EnablePathEscape when is true then its escapes the path, the named parameters (if any).
    // Change to false it if you want something like this https://github.com/kataras/iris/issues/135 to work
    //
    // When do you need to Disable(false) it:
    // accepts parameters with slash '/'
    // Request: http://localhost:8080/details/Project%2FDelta
    // ctx.Param("project") returns the raw named parameter: Project%2FDelta
    // which you can escape it manually with net/url:
    // projectName, _ := url.QueryUnescape(c.Param("project").
    //
    // Defaults to false.
    EnablePathEscape bool `json:"enablePathEscape,omitempty" yaml:"EnablePathEscape" toml:"EnablePathEscape"`

    // EnableOptimization when this field is true
    // then the application tries to optimize for the best performance where is possible.
    //
    // Defaults to false.
    EnableOptimizations bool `json:"enableOptimizations,omitempty" yaml:"EnableOptimizations" toml:"EnableOptimizations"`
    // FireMethodNotAllowed if it's true router checks for StatusMethodNotAllowed(405) and
    //  fires the 405 error instead of 404
    // Defaults to false.
    FireMethodNotAllowed bool `json:"fireMethodNotAllowed,omitempty" yaml:"FireMethodNotAllowed" toml:"FireMethodNotAllowed"`

    // DisableBodyConsumptionOnUnmarshal manages the reading behavior of the context's body readers/binders.
    // If set to true then it
    // disables the body consumption by the `context.UnmarshalBody/ReadJSON/ReadXML`.
    //
    // By-default io.ReadAll` is used to read the body from the `context.Request.Body which is an `io.ReadCloser`,
    // if this field set to true then a new buffer will be created to read from and the request body.
    // The body will not be changed and existing data before the
    // context.UnmarshalBody/ReadJSON/ReadXML will be not consumed.
    DisableBodyConsumptionOnUnmarshal bool `json:"disableBodyConsumptionOnUnmarshal,omitempty" yaml:"DisableBodyConsumptionOnUnmarshal" toml:"DisableBodyConsumptionOnUnmarshal"`

    // DisableAutoFireStatusCode if true then it turns off the http error status code handler automatic execution
    // from (`context.StatusCodeNotSuccessful`, defaults to < 200 || >= 400).
    // If that is false then for a direct error firing, then call the "context#FireStatusCode(statusCode)" manually.
    //
    // By-default a custom http error handler will be fired when "context.StatusCode(code)" called,
    // code should be equal with the result of the the `context.StatusCodeNotSuccessful` in order to be received as an "http error handler".
    //
    // Developer may want this option to set as true in order to manually call the
    // error handlers when needed via "context#FireStatusCode(< 200 || >= 400)".
    // HTTP Custom error handlers are being registered via app.OnErrorCode(code, handler)".
    //
    // Defaults to false.
    DisableAutoFireStatusCode bool `json:"disableAutoFireStatusCode,omitempty" yaml:"DisableAutoFireStatusCode" toml:"DisableAutoFireStatusCode"`

    // TimeFormat time format for any kind of datetime parsing
    // Defaults to  "Mon, 02 Jan 2006 15:04:05 GMT".
    TimeFormat string `json:"timeFormat,omitempty" yaml:"TimeFormat" toml:"TimeFormat"`

    // Charset character encoding for various rendering
    // used for templates and the rest of the responses
    // Defaults to "UTF-8".
    Charset string `json:"charset,omitempty" yaml:"Charset" toml:"Charset"`

    // PostMaxMemory sets the maximum post data size
    // that a client can send to the server, this differs
    // from the overral request body size which can be modified
    // by the `context#SetMaxRequestBodySize` or `iris#LimitRequestBodySize`.
    //
    // Defaults to 32MB or 32 << 20 if you prefer.
    PostMaxMemory int64 `json:"postMaxMemory" yaml:"PostMaxMemory" toml:"PostMaxMemory"`
    //  +----------------------------------------------------+
    //  | Context's keys for values used on various featuers |
    //  +----------------------------------------------------+

    // Context values' keys for various features.
    //
    // LocaleContextKey is used by i18n to get the current request's locale, which contains a translate function too.
    //
    // Defaults to "iris.locale".
    LocaleContextKey string `json:"localeContextKey,omitempty" yaml:"LocaleContextKey" toml:"LocaleContextKey"`

    // GetViewLayoutContextKey is the key of the context's user values' key
    // which is being used to set the template
    // layout from a middleware or the main handler.
    // Overrides the parent's or the configuration's.
    //
    // Defaults to "iris.ViewLayout"
    ViewLayoutContextKey string `json:"viewLayoutContextKey,omitempty" yaml:"ViewLayoutContextKey" toml:"ViewLayoutContextKey"`
    // GetViewDataContextKey is the key of the context's user values' key
    // which is being used to set the template
    // binding data from a middleware or the main handler.
    //
    // Defaults to "iris.viewData"
    ViewDataContextKey string `json:"viewDataContextKey,omitempty" yaml:"ViewDataContextKey" toml:"ViewDataContextKey"`
    // RemoteAddrHeaders are the allowed request headers names
    // that can be valid to parse the client's IP based on.
    // By-default no "X-" header is consired safe to be used for retrieving the
    // client's IP address, because those headers can manually change by
    // the client. But sometimes are useful e.g., when behind a proxy
    // you want to enable the "X-Forwarded-For" or when cloudflare
    // you want to enable the "CF-Connecting-IP", inneed you
    // can allow the `ctx.RemoteAddr()` to use any header
    // that the client may sent.
    //
    // Defaults to an empty map but an example usage is:
    // RemoteAddrHeaders {
    //  "X-Real-Ip":             true,
    //  "X-Forwarded-For":       true,
    //  "CF-Connecting-IP":      true,
    //  }
    //
    // Look `context.RemoteAddr()` for more.
    RemoteAddrHeaders map[string]bool `json:"remoteAddrHeaders,omitempty" yaml:"RemoteAddrHeaders" toml:"RemoteAddrHeaders"`

    // Other are the custom, dynamic options, can be empty.
    // This field used only by you to set any app's options you want.
    //
    // Defaults to a non-nil empty map.
    Other map[string]interface{} `json:"other,omitempty" yaml:"Other" toml:"Other"`
}

相关文章

  • iris-配置项

    以下内容摘自源代码configuration.go

  • iris-配置

    iris支持四种配置方式:结构方式(struction),toml文件方式,yaml文件方式,编程方式(funct...

  • eureka(三) eureka配置文件

    Eureka instance 配置项 Eureka client 配置项 Eureka Server 配置项 s...

  • iris-开始

    iris是golang的web框架,官方地址:https://github.com/kataras/iris/,支...

  • Nginx的配置

    Nginx的配置 配置语法 默认的配置文件nginx.conf 块配置项 块配置项由一个块配置项名称和一对大括号组...

  • 配置项

    Vim 有很多配置项,通过修改配置项的值可以改变 vim 的行为。 Vim 里有两类配置项,一类是布尔值配置项(只...

  • echarts 相关label配置

    eacarts API 配置项:echart API echart option配置项 let option =...

  • 配置管理过程域实施要点

    专用目标1 建立基线 专用实践1.1 标识配置项 标识配置项要求把所有应纳入配置管理的配置项标识出来。为此: 1)...

  • 配置项

    待配置列表 vim 设置 sublime text 3 设置与插件 chrome 插件 系统时间修改 SoftWa...

  • 系统集成都考什么,需要注意什么

    配置项版本号规则 配置项的版本号规则与配置项的状态相关。 (1)处于“草稿”状态的配置项的版本号格式为0.YZ,Y...

网友评论

      本文标题:iris-配置项

      本文链接:https://www.haomeiwen.com/subject/bwvffhtx.html