44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
|
package host
|
||
|
|
||
|
import (
|
||
|
"net/http"
|
||
|
|
||
|
"github.com/astaxie/session"
|
||
|
"github.com/jinzhu/gorm"
|
||
|
"github.com/julienschmidt/httprouter"
|
||
|
|
||
|
libconfig "dev.sum7.de/sum7/warehost/config"
|
||
|
libapi "dev.sum7.de/sum7/warehost/lib/api"
|
||
|
log "dev.sum7.de/sum7/warehost/lib/log"
|
||
|
)
|
||
|
|
||
|
//MODULNAME to get global name for the modul
|
||
|
const MODULNAME = "host"
|
||
|
|
||
|
//API keep data in module global
|
||
|
type API struct {
|
||
|
config *libconfig.Config
|
||
|
sessions *session.Manager
|
||
|
dbconnection *gorm.DB
|
||
|
log *log.ModulLog
|
||
|
}
|
||
|
|
||
|
// NewAPI sets the routes to the api functions
|
||
|
func NewAPI(config *libconfig.Config, sessions *session.Manager, dbconnection *gorm.DB, router *httprouter.Router, prefix string) {
|
||
|
api := &API{
|
||
|
config: config,
|
||
|
sessions: sessions,
|
||
|
dbconnection: dbconnection,
|
||
|
log: log.NewModulLog(MODULNAME),
|
||
|
}
|
||
|
router.GET(prefix+"/status", libapi.SessionHandler(api.Status, sessions))
|
||
|
}
|
||
|
|
||
|
// Status to get Login and Server status
|
||
|
func (api *API) Status(w http.ResponseWriter, r *http.Request, _ httprouter.Params, sess session.Session) (returndata interface{}, returnerr *libapi.ErrorResult) {
|
||
|
returndata = true
|
||
|
logger := api.log.GetLog(r, "status")
|
||
|
logger.Info("status")
|
||
|
return
|
||
|
}
|