diff --git a/cmd/main.go b/cmd/main.go index aa1c38f..2318010 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -1,6 +1,7 @@ package main import ( + "flag" "fmt" "math/rand" "net/http" @@ -28,6 +29,14 @@ type StatsFormData struct { var linkMap = map[string]*models.Link{} +var baseurl *string + +func init() { + baseurl = flag.String("url", "127.0.0.1:8080", "The url (domain) that the server is running on") + + flag.Parse() +} + func main() { e := echo.New() @@ -86,7 +95,7 @@ func SubmitHandler(c echo.Context) error { linkMap[id] = &models.Link{Id: id, Url: data.Url} - return views.Submission(id).Render(c.Request().Context(), c.Response()) + return views.Submission(id, *baseurl).Render(c.Request().Context(), c.Response()) } func StatsHandler(c echo.Context) error { diff --git a/docker-compose.yml b/docker-compose.yml index 64779d4..139f93b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,4 +6,5 @@ services: dockerfile: Dockerfile ports: - "8080:8080" - restart: unless-stopped \ No newline at end of file + restart: unless-stopped + command: ["/shortr", "--url", "app.4rkal.com"] diff --git a/views/submit.templ b/views/submit.templ index 2c43841..7016910 100644 --- a/views/submit.templ +++ b/views/submit.templ @@ -1,9 +1,9 @@ package views -templ Submission(url string){ +templ Submission(url, baseurl string){ @Base() { -
{baseurl + "/" + url}