feat: added cacerts and some tidying
This commit is contained in:
parent
2112e7eefd
commit
bdd85b01ff
8 changed files with 279 additions and 59 deletions
|
|
@ -19,9 +19,10 @@ import (
|
|||
)
|
||||
|
||||
type Service struct {
|
||||
Addr string
|
||||
RootPath string `yaml:"root,omitempty"`
|
||||
Environment map[string]string
|
||||
Addr string
|
||||
RootPath string `yaml:"root,omitempty"`
|
||||
CACertFile string `yaml:"cacert,omitempty"`
|
||||
CACertKeyfile string `yaml:"keyfile,omitempty"`
|
||||
|
||||
// max counts
|
||||
PluginsMaxCount int
|
||||
|
|
@ -32,13 +33,8 @@ type Service struct {
|
|||
// New creates a new Service instance with default values
|
||||
func New() *Service {
|
||||
return &Service{
|
||||
Addr: ":5050",
|
||||
RootPath: "./",
|
||||
Environment: map[string]string{
|
||||
"MAKESHIFT_HOST": "",
|
||||
"MAKESHIFT_ROOT": "",
|
||||
"ACCESS_TOKEN": "",
|
||||
},
|
||||
Addr: ":5050",
|
||||
RootPath: "./",
|
||||
PluginsMaxCount: DEFAULT_PLUGINS_MAX_COUNT,
|
||||
ProfilesMaxCount: DEFAULT_PROFILES_MAX_COUNT,
|
||||
Timeout: DEFAULT_TIMEOUT_IN_SECS,
|
||||
|
|
@ -121,7 +117,11 @@ func (s *Service) Serve() error {
|
|||
|
||||
// always available public routes go here
|
||||
router.HandleFunc("/status", s.GetStatus)
|
||||
return http.ListenAndServe(s.Addr, router)
|
||||
if s.CACertFile != "" && s.CACertKeyfile != "" {
|
||||
return http.ListenAndServeTLS(s.Addr, s.CACertFile, s.CACertKeyfile, router)
|
||||
} else {
|
||||
return http.ListenAndServe(s.Addr, router)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Service) requireAuth() bool {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue