通过程序内部配置

    通过TOML配置文件

    1. EnablePathEscape = false
    2. FireMethodNotAllowed = true
    3. DisableBodyConsumptionOnUnmarshal = false
    4. TimeFormat = "Mon, 01 Jan 2006 15:04:05 GMT"
    5. Charset = "UTF-8"
    6. [Other]
    7. MyServerName = "iris"

    通过YAML配置文件

    1. DisablePathCorrection: false
    2. EnablePathEscape: false
    3. FireMethodNotAllowed: true
    4. DisableBodyConsumptionOnUnmarshal: true
    5. TimeFormat: Mon, 01 Jan 2006 15:04:05 GMT
    6. Charset: UTF-8

    Built'n配置器

    1. // err := app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed))
    2. // 当配置此项 如果web服务器 出现异常 我们将返回nil.
    3. // 参考`Configuration的IgnoreServerErrors方法
    4. func WithoutServerError(errors ...error) Configurator
    5. //Now listening on: http://localhost:8080
    6. // Application started. Press CTRL+C to shut down.
    7. var WithoutStartupLog
    8. //当按下ctrl+C 时 禁止关闭当前程序(不会中止程序的运行)
    9. var WithoutInterruptHandler
    10. //路径重新定义(默认关闭)比如当访问/user/info 当该路径不存在的时候自动访问/user对应的handler
    11. var WithoutPathCorrection
    12. //如果此字段设置为true,则将创建一个新缓冲区以从请求主体读取。
    13. var WithoutBodyConsumptionOnUnmarshal
    14. //如果为true则关闭http错误状态代码处理程序自动执行
    15. var WithoutAutoFireStatusCode
    16. //转义路径
    17. //开启优化
    18. var WithOptimizations
    19. //不允许重新指向方法
    20. var WithFireMethodNotAllowed
    21. //设置时间格式
    22. func WithTimeFormat(timeformat string) Configurator
    23. //设值程序字符集
    24. func WithCharset(charset string) Configurator
    25. //启用或添加新的或现有的请求标头名称
    26. func WithRemoteAddrHeader(headerName string) Configurator
    27. //取消现有的请求标头名称
    28. func WithoutRemoteAddrHeader(headerName string) Configurator
    29. //自定义配置 key=>value