sum7/warehost
sum7
/
warehost
Archived
1
0
Fork 0
This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
warehost/modul/host/api.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
}