Add domain cli option.
This commit is contained in:
parent
7f06794dc2
commit
21dc8f1fa1
15
main.go
15
main.go
@ -22,16 +22,21 @@ var templates embed.FS
|
|||||||
//go:embed all:static/*
|
//go:embed all:static/*
|
||||||
var static embed.FS
|
var static embed.FS
|
||||||
|
|
||||||
|
var domain string
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
t := &Template{
|
t := &Template{
|
||||||
templates: template.Must(template.ParseFS(templates, "public/views/*.html")),
|
templates: template.Must(template.ParseFS(templates, "public/views/*.html")),
|
||||||
}
|
}
|
||||||
|
|
||||||
port := flag.Int("p", 1323, "upfast port to listen on.")
|
p := flag.Int("p", 1323, "upfast port to listen on.")
|
||||||
adress := flag.String("a", "127.0.0.1", "upfast ip to listen to")
|
a := flag.String("a", "127.0.0.1", "upfast ip to listen to")
|
||||||
|
d := flag.String("d", "127.0.0.1", "upfast domain")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
host := *adress + ":" + strconv.Itoa(*port)
|
host := *a + ":" + strconv.Itoa(*p)
|
||||||
|
|
||||||
|
domain = *d
|
||||||
|
|
||||||
e := echo.New()
|
e := echo.New()
|
||||||
|
|
||||||
@ -91,7 +96,7 @@ func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Con
|
|||||||
|
|
||||||
func Index(c echo.Context) error {
|
func Index(c echo.Context) error {
|
||||||
data := IndexData{
|
data := IndexData{
|
||||||
Host: c.Request().Host,
|
Host: domain,
|
||||||
}
|
}
|
||||||
return c.Render(http.StatusOK, "index", data)
|
return c.Render(http.StatusOK, "index", data)
|
||||||
}
|
}
|
||||||
@ -191,7 +196,7 @@ func Upload(c echo.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fileUrl := c.Request().Host + "/files/" + file.Filename + "\n"
|
fileUrl := domain + "/files/" + file.Filename + "\n"
|
||||||
|
|
||||||
UserAgent := c.Request().UserAgent()
|
UserAgent := c.Request().UserAgent()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user