2017-11-10 12:39:55 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2018-09-22 17:27:48 +02:00
|
|
|
"flag"
|
2017-11-10 12:39:55 +01:00
|
|
|
"net/http"
|
|
|
|
|
|
|
|
web "fornaxian.com/pixeldrain-web/init"
|
|
|
|
|
2018-06-17 16:15:58 +02:00
|
|
|
"github.com/Fornaxian/log"
|
2017-11-10 12:39:55 +01:00
|
|
|
"github.com/julienschmidt/httprouter"
|
|
|
|
)
|
|
|
|
|
|
|
|
// This is just a launcher for the web server. During testing the app would
|
|
|
|
// be directly embedded by another Go project. And when deployed it will run
|
|
|
|
// independently.
|
|
|
|
func main() {
|
2018-09-22 17:27:48 +02:00
|
|
|
var listen = flag.String("listen", ":8081", "The address which the API server will listen on")
|
|
|
|
var prefix = flag.String("prefix", "", "Prefix that comes before the API URL")
|
|
|
|
flag.Parse()
|
|
|
|
|
2017-11-10 12:39:55 +01:00
|
|
|
r := httprouter.New()
|
|
|
|
|
2018-09-22 17:27:48 +02:00
|
|
|
web.Init(r, *prefix, true)
|
2017-11-10 12:39:55 +01:00
|
|
|
|
2018-09-22 17:27:48 +02:00
|
|
|
err := http.ListenAndServe(*listen, r)
|
2017-11-10 12:39:55 +01:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Error("Can't listen and serve Pixeldrain Web: %v", err)
|
|
|
|
}
|
|
|
|
}
|