diff --git a/handlers.go b/handlers.go index 445c7c6..6020a59 100755 --- a/handlers.go +++ b/handlers.go @@ -19,7 +19,7 @@ import ( var customCSS []byte -func serve(host, port, crt_path, key_path string, TLS bool, cssFile string) { +func serve(host, port, crt_path, key_path string, TLS bool, cssFile string, defaultPage string) { gin.SetMode(gin.ReleaseMode) router := gin.Default() store := sessions.NewCookieStore([]byte("secret")) @@ -27,7 +27,11 @@ func serve(host, port, crt_path, key_path string, TLS bool, cssFile string) { router.HTMLRender = loadTemplates("index.tmpl") // router.Use(static.Serve("/static/", static.LocalFile("./static", true))) router.GET("/", func(c *gin.Context) { - c.Redirect(302, "/"+randomAlliterateCombo()) + if defaultPage != "" { + c.Redirect(302, "/"+defaultPage+"/read") + } else { + c.Redirect(302, "/"+randomAlliterateCombo()) + } }) router.GET("/:page", func(c *gin.Context) { page := c.Param("page") diff --git a/main.go b/main.go index 1c46a93..4bbe4b3 100755 --- a/main.go +++ b/main.go @@ -38,7 +38,7 @@ func main() { } else { fmt.Printf("\nRunning cowyo server (version %s) at http://%s:%s\n\n", version, host, c.GlobalString("port")) } - serve(c.GlobalString("host"), c.GlobalString("port"), c.GlobalString("cert"), c.GlobalString("key"), TLS, c.GlobalString("css")) + serve(c.GlobalString("host"), c.GlobalString("port"), c.GlobalString("cert"), c.GlobalString("key"), TLS, c.GlobalString("css"), c.GlobalString("default-page")) return nil } app.Flags = []cli.Flag{ @@ -77,6 +77,11 @@ func main() { Value: "", Usage: "use a custom CSS file", }, + cli.StringFlag{ + Name: "default-page", + Value: "", + Usage: "show default-page/read instead of editing", + }, cli.BoolFlag{ Name: "debug, d", Usage: "turn on debugging",