From e9feea48984306b9a447f3b714b820c70fa29e79 Mon Sep 17 00:00:00 2001 From: Malte Reddig Date: Mon, 5 Oct 2020 13:36:27 +0200 Subject: [PATCH] Add HOSTNAME Env Variable The HOSTNAME Env Variable adapts the HTML template to the current hostname. This is by default `ifconfig.io` --- main.go | 2 ++ templates/index.html | 30 +++++++++++++++--------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/main.go b/main.go index 60a5d54..f8b16b1 100644 --- a/main.go +++ b/main.go @@ -60,6 +60,8 @@ func mainHandler(c *gin.Context) { // return //} + c.Set("ifconfig_hostname", getEnvWithDefault("HOSTNAME", "ifconfig.io")) + c.Set("ip", ip.IP.String()) c.Set("port", ip.Port) c.Set("ua", c.Request.UserAgent()) diff --git a/templates/index.html b/templates/index.html index 34fc355..328188d 100644 --- a/templates/index.html +++ b/templates/index.html @@ -9,12 +9,12 @@ /* Customizations. */ li.list-group-item{overflow:auto;padding-top:6px;padding-bottom:6px;}header.page-header{margin-top:20px;}a.h1{color:inherit;text-decoration:none;}@media(max-width: 750px){div.col-sm-3{font-weight:700;}} - ifconfig.io + {{ .ifconfig_hostname }} @@ -65,43 +65,43 @@