Merge branch 'develop' of github.com:Pterodactyl/wings into develop

# Conflicts:
#	api/api.go
#	api/core_routes.go
#	api/handlers_server.go
#	api/routes_server.go
#	config.example.json
#	utils/logging.go
This commit is contained in:
Jakob Schrettenbrunner
2017-10-01 20:59:32 +02:00
16 changed files with 94 additions and 162 deletions

View File

@@ -11,23 +11,25 @@ import (
"github.com/Pterodactyl/wings/config"
)
// API is a grouping struct for the api
type API struct {
type InternalAPI struct {
router *gin.Engine
}
// NewAPI creates a new Api object
func NewAPI() API {
return API{}
func NewAPI() InternalAPI {
return InternalAPI{}
}
// Listen starts the api http server
func (api *API) Listen() {
// Configure the API and begin listening on the configured IP and Port.
func (api *InternalAPI) Listen() {
listener := fmt.Sprintf("%s:%d", viper.GetString(config.APIHost), viper.GetInt(config.APIPort))
if !viper.GetBool(config.Debug) {
gin.SetMode(gin.ReleaseMode)
}
api.router = gin.Default()
api.router.RedirectTrailingSlash = false
api.RegisterRoutes()
api.router.Use(func(c *gin.Context) {
c.Header("Access-Control-Allow-Origin", "*")
@@ -47,7 +49,3 @@ func (api *API) Listen() {
log.Info("Now listening on %s", listenString)
log.Fatal(http.ListenAndServe(listenString, nil))
}
func getRoot(c *gin.Context) {
c.String(http.StatusOK, "hello!")
}