mirror of
https://github.com/kataras/iris.git
synced 2025-12-24 05:17:03 +00:00
Version 3.0.0-beta cleaned
This commit is contained in:
44
config/server.go
Normal file
44
config/server.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/imdario/mergo"
|
||||
)
|
||||
|
||||
const (
|
||||
// DefaultServerAddr the default server addr
|
||||
DefaultServerAddr = ":8080"
|
||||
)
|
||||
|
||||
// ServerName the response header of the 'Server' value when writes to the client
|
||||
const ServerName = "iris"
|
||||
|
||||
// Server used inside server for listening
|
||||
type Server struct {
|
||||
// ListenningAddr the addr that server listens to
|
||||
ListeningAddr string
|
||||
CertFile string
|
||||
KeyFile string
|
||||
// Mode this is for unix only
|
||||
Mode os.FileMode
|
||||
}
|
||||
|
||||
// DefaultServer returns the default configs for the server
|
||||
func DefaultServer() Server {
|
||||
return Server{DefaultServerAddr, "", "", 0}
|
||||
}
|
||||
|
||||
// Merge merges the default with the given config and returns the result
|
||||
func (c Server) Merge(cfg []Server) (config Server) {
|
||||
|
||||
if len(cfg) > 0 {
|
||||
config = cfg[0]
|
||||
mergo.Merge(&config, c)
|
||||
} else {
|
||||
_default := c
|
||||
config = _default
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user