Example #1
0
func main() {
	restHandler := new(rest.DeviceRestGetHandler)
	pageHandler := new(rest.PageRestGetHandler)
	myhttp.NewHttpHandler("/device/", restHandler)
	myhttp.NewHttpHandler("/page/", pageHandler)
	http.ListenAndServe(fmt.Sprintf(":%d", config.GetRestPort()), nil)
}
Example #2
0
func (t *PageRestGetHandler) GeneratePage(w http.ResponseWriter, page string) {
	log.Print("Generate Page " + page)
	content, err := ioutil.ReadFile("webContent/" + page)
	devicesTemplate, err := template.New("Geräte").Parse(fmt.Sprintf("%s", content))

	if err != nil {
		log.Print("Error while generating Page " + page)
		fmt.Fprintf(w, "%s", err)
		return
	}

	siteData := SiteData{
		RestPort:  config.GetRestPort(),
		IpAddress: GetIp(),
	}

	err = devicesTemplate.Execute(w, siteData)

	if err != nil {
		log.Print("Error while generating Page " + page)
		fmt.Fprintf(w, "%s", err)
		return
	}
}