1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-18 08:26:45 +02:00
woodpecker/shared/server/server.go
2015-09-29 18:21:17 -07:00

37 lines
623 B
Go

package server
import (
"net/http"
log "github.com/Sirupsen/logrus"
"github.com/drone/drone/shared/envconfig"
)
type Server struct {
Addr string
Cert string
Key string
}
func Load(env envconfig.Env) *Server {
return &Server{
Addr: env.String("SERVER_ADDR", ":8000"),
Cert: env.String("SERVER_CERT", ""),
Key: env.String("SERVER_KEY", ""),
}
}
func (s *Server) Run(handler http.Handler) {
log.Infof("starting server %s", s.Addr)
if len(s.Cert) != 0 {
log.Fatal(
http.ListenAndServeTLS(s.Addr, s.Cert, s.Key, handler),
)
} else {
log.Fatal(
http.ListenAndServe(s.Addr, handler),
)
}
}