outpost/proxy: show better error when hostname isn't configured
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
88516ba2ca
commit
97b814ab33
|
@ -1,6 +1,8 @@
|
||||||
package proxyv2
|
package proxyv2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -60,7 +62,23 @@ func (ps *ProxyServer) Handle(rw http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ps.log.WithField("host", host).Warning("no app for hostname")
|
ps.log.WithField("host", host).Warning("no app for hostname")
|
||||||
rw.WriteHeader(400)
|
|
||||||
|
rw.Header().Set("Content-Type", "application/json")
|
||||||
|
rw.WriteHeader(http.StatusBadRequest)
|
||||||
|
j := json.NewEncoder(rw)
|
||||||
|
j.SetIndent("", "\t")
|
||||||
|
err := j.Encode(struct {
|
||||||
|
Message string
|
||||||
|
Host string
|
||||||
|
Detail string
|
||||||
|
}{
|
||||||
|
Message: "no app for hostname",
|
||||||
|
Host: host,
|
||||||
|
Detail: fmt.Sprintf("Check the outpost settings and make sure '%s' is included.", host),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
ps.log.WithError(err).Warning("Failed to write error body")
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ps.log.WithField("host", host).Trace("passing to application mux")
|
ps.log.WithField("host", host).Trace("passing to application mux")
|
||||||
|
|
|
@ -73,7 +73,7 @@ export class OutpostForm extends ModelForm<Outpost, string> {
|
||||||
value=${ifDefined(provider.pk)}
|
value=${ifDefined(provider.pk)}
|
||||||
?selected=${selected}
|
?selected=${selected}
|
||||||
>
|
>
|
||||||
${provider.assignedApplicationName} (${provider.name})
|
${provider.assignedApplicationName} (${provider.externalHost})
|
||||||
</option>`;
|
</option>`;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Reference in New Issue