2022-03-24 00:49:23 +01:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Template struct {
|
|
|
|
Type string
|
|
|
|
Content string
|
|
|
|
Config string
|
|
|
|
}
|
|
|
|
|
2022-06-27 15:58:37 +02:00
|
|
|
func Generate(c *gin.Context) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
2022-03-24 00:49:23 +01:00
|
|
|
func Generate(c *gin.Context) {
|
|
|
|
var template Template
|
|
|
|
|
|
|
|
err := c.Request.ParseForm()
|
|
|
|
if err != nil {
|
|
|
|
c.String(500, err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
err = c.ShouldBindJSON(&template)
|
|
|
|
if err != nil {
|
|
|
|
c.String(500, err.Error())
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
templateType := template.Type
|
|
|
|
templateFile := template.Content
|
|
|
|
config := []byte(template.Config)
|
|
|
|
res := ""
|
|
|
|
if templateType == "go" {
|
|
|
|
res = templater.ProcessGoTemplate(templateFile, config)
|
|
|
|
c.JSON(http.StatusOK, gin.H{"data": res})
|
|
|
|
} else if templateType == "hcl" {
|
|
|
|
res = templater.ProcessHCLTemplate(templateFile, config)
|
|
|
|
c.JSON(http.StatusOK, gin.H{"data": res})
|
|
|
|
} else {
|
|
|
|
c.JSON(http.StatusBadRequest, gin.H{"data": "Unkown template type"})
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2022-06-27 15:58:37 +02:00
|
|
|
*/
|