package main import ( "flag" "net/http" "sectorinf.com/emilis/fupie/logie" "sectorinf.com/emilis/fupie/ws" "sectorinf.com/emilis/fupie/ws/html" "sectorinf.com/emilis/fupie/ws/route" ) func main() { var ( uploadsPath = flag.String("path", ".", "Path to upload files to") redirectPath = flag.String("redirect", "http://localhost:8008", "URI part to add the uploaded filename to for redirects") host = flag.String("host", "127.0.0.1:8008", "Hostname to listen to") ) flag.Parse() log := logie.New() router := route.New(log).Group("v1", func(r route.Router) route.Router { upload, err := ws.Upload(*uploadsPath, *redirectPath, 1<<20) if err != nil { log.Fatal(err.Error()) } r.POST("upload", upload) return r }). GET("/", html.Index). Middleware(ws.LoggingMiddleware(log)) log.ColorBracket(0, logie.Colors().Background(logie.ColorWhite).Foreground(logie.ColorBlack)).Infof("Starting server on [%s]", host) log.Fatal(http.ListenAndServe(*host, router)) }