Files
gf/g/net/ghttp/http_server_config.go
2017-12-31 18:19:58 +08:00

52 lines
1.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Copyright 2017 gf Author(https://gitee.com/johng/gf). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://gitee.com/johng/gf.
package ghttp
import (
"net/http"
"crypto/tls"
"time"
"log"
)
// HTTP Server 设置结构体
type ServerConfig struct {
// HTTP Server基础字段
Addr string // 监听IP和端口监听本地所有IP使用":端口"
Handler http.Handler // 默认的处理函数
TLSConfig *tls.Config // TLS配置
ReadTimeout time.Duration
WriteTimeout time.Duration
IdleTimeout time.Duration
MaxHeaderBytes int // 最大的header长度
ErrorLog *log.Logger // 错误日志的处理接口
// gf 扩展信息字段
IndexFiles []string // 默认访问的文件列表
IndexFolder bool // 如果访问目录是否显示目录列表
ServerAgent string // server agent
ServerRoot string // 服务器服务的本地目录根路径
}
// 默认HTTP Server
var defaultServerConfig = ServerConfig {
Addr : ":80",
Handler : nil,
ReadTimeout : 60 * time.Second,
WriteTimeout : 60 * time.Second,
IdleTimeout : 60 * time.Second,
MaxHeaderBytes : 1024,
IndexFiles : []string{"index.html", "index.htm"},
IndexFolder : false,
ServerAgent : "gf",
ServerRoot : "",
}
// 获取默认的http server设置
func DefaultSetting() ServerConfig {
return defaultServerConfig
}