Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "github.com/gin-gonic/gin"
- "fmt"
- "net/http"
- "io/ioutil"
- // "path/filepath"
- // "html/template"
- )
- func init() {
- fmt.Println("Start cigo") // ^_^
- }
- func main() {
- router := gin.Default()
- router.StaticFile("/favicon.ico", "./img/favicon.ico")
- router.Static("/assets", "./assets")
- router.LoadHTMLGlob("templates/*") // templates files
- router.GET("/", home)
- router.GET("/config", config)
- router.GET("/builds", showBuilds)
- router.GET("/builds/:build_name", editBuilds)
- // Builds routes
- /* v1 := router.Group("/builds/:buildname")
- {
- v1.POST("/login", loginEndpoint)
- v1.POST("/submit", submitEndpoint)
- v1.POST("/read", readEndpoint)
- }*/
- //router.POST("/api/:name", apiTest)
- router.Run(":7000")
- }
- func checkErr(e error) {
- if e != nil {
- panic(e)
- }
- }
- func home(c *gin.Context) {
- c.HTML(http.StatusOK, "index", gin.H{ // index it's template name (index.tmpl
- "title": "cigo : GO Continiuos Integration",
- "appname": "cigo Deploy",
- "headertext": "Hello world!",
- })
- }
- func config(c *gin.Context) {
- c.HTML(http.StatusOK, "index", gin.H{ // index.tmpl
- "title": "cigo : Config page",
- "appname": "cigo Deploy",
- "headertext": "cigo Config",
- })
- }
- func showBuilds(c *gin.Context) {
- build_files, err := ioutil.ReadDir("./builds")
- checkErr(err)
- fmt.Printf("%v", build_files)
- c.HTML(http.StatusOK, "builds", gin.H{ // builds.tmpl
- "title": "cigo : Config page",
- "appname": "cigo Deploy",
- "headertext": "Builds list",
- "FileInfo" : build_files,
- })
- }
- func editBuilds(c *gin.Context) {
- // build_name := c.Param("build_name")
- fmt.Println("editBuilds func exec")
- //build_raw = ioutil.ReadFile("builds/" + build_name)
- //fmt.Printf("%v", build_raw)
- c.HTML(http.StatusOK, "edit_build", gin.H{ // edit_build.tmpl
- "title": "cigo : Config page",
- "appname": "cigo Deploy",
- "headertext": "Builds list",
- "editFile": "data",
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement