This commit is contained in:
2021-01-03 17:31:16 -05:00
parent d524f0c3f4
commit e0974f5ff2
8 changed files with 235 additions and 37 deletions

View File

@@ -1,23 +1,24 @@
package cmd
import (
"github.com/urfave/cli"
"github.com/go-macaron/gzip"
"gopkg.in/macaron.v1"
"reichard.io/imagini/routes"
"github.com/urfave/cli/v2"
"net/http"
"log"
)
var CmdServe = cli.Command{
Name: "serve",
Usage: "Start Imagini web server.",
Action: serveWeb,
Name: "serve",
Aliases: []string{"s"},
Usage: "Start Imagini web server.",
Action: serveWeb,
}
func serveWeb(ctx *cli.Context) error {
m := macaron.Classic()
m.Get("/", func() string {
return "Hello world!"
})
m.Use(gzip.Gziper())
m.Run()
routes.RegisterRoutes()
if err := http.ListenAndServe(":8080", nil); err != nil {
log.Fatal(err)
}
return nil
}