package util import ( "gitlab.thpeetz.de/kontor/kontor-go/pkg/auth" "net/http" "github.com/gin-gonic/gin" ) const ( // SaveAction defines label of button. SaveAction = "Save" // AddAction defines label of button. AddAction = "Add" // DeleteAction defines label of button. DeleteAction = "Delete" ) // Render one of HTML, JSON or CSV based on the 'Accept' header of the request // If the header doesn't specify this, HTML is rendered, provided that // the template name is present func Render(c *gin.Context, data gin.H, templateName string) { auth.SetSessionData(c, data) switch c.Request.Header.Get("Accept") { case "application/json": c.JSON(http.StatusOK, data["payload"]) case "application/xml": c.XML(http.StatusOK, data["payload"]) default: c.HTML(http.StatusOK, templateName, data) } } // ShowIndexPage render the index page of Kontor web application. func ShowIndexPage(c *gin.Context) { // Call the render function with the name of the template to render //log.Printf("Context: %v", c) Render(c, gin.H{"title": "Kontor", "payload": nil}, "kontor/index.html") }