Add initial API support for listing configured servers

This commit is contained in:
Dane Everitt
2019-04-05 22:20:26 -07:00
parent ec2407481b
commit cedbee5080
5 changed files with 67 additions and 20 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"github.com/pterodactyl/wings/server"
"go.uber.org/zap"
"net/http"
)
// Entrypoint for the Wings application. Configures the logger and checks any
@@ -50,6 +51,16 @@ func main() {
zap.S().Errorw("failed to create an environment for server", zap.String("server", s.Uuid), zap.Error(err))
}
}
r := &Router{
Servers: servers,
}
router := r.ConfigureRouter()
zap.S().Infow("configuring webserver", zap.String("host", c.Api.Host), zap.Int("port", c.Api.Port))
if err := http.ListenAndServe(fmt.Sprintf("%s:%d", c.Api.Host, c.Api.Port), router); err != nil {
zap.S().Fatalw("failed to configure HTTP server", zap.Error(err))
}
}
// Configures the global logger for Zap so that we can call it from any location