Take the hostname from the request

This commit is contained in:
Las Zenow 2020-02-20 23:52:51 +00:00
parent 3e3ba1bd7e
commit 3bb3cf9489
3 changed files with 8 additions and 9 deletions

View file

@ -24,7 +24,6 @@ type handler struct {
db database.DB
store storage.Store
template *Template
hostname string
ro bool
t1 time.Time
}
@ -79,12 +78,11 @@ type StatsGatherer struct {
store storage.Store
template *Template
instrument instrument.Instrument
hostname string
channel chan statsRequest
ro bool
}
func InitStats(database database.DB, store storage.Store, hostname string, template *Template, ro bool) *StatsGatherer {
func InitStats(database database.DB, store storage.Store, template *Template, ro bool) *StatsGatherer {
in := instrument.Init()
sg := StatsGatherer{
@ -93,7 +91,6 @@ func InitStats(database database.DB, store storage.Store, hostname string, templ
store: store,
instrument: in,
template: template,
hostname: hostname,
ro: ro,
}
@ -109,7 +106,6 @@ func (sg StatsGatherer) Gather(function func(handler)) func(http.ResponseWriter,
store: sg.store,
db: sg.db,
template: sg.template,
hostname: sg.hostname,
w: w,
r: r,
sess: GetSession(r, sg.db),

View file

@ -36,7 +36,11 @@ type Status struct {
func GetStatus(h handler) Status {
var s Status
s.BaseURL = "http://" + h.hostname
host := h.r.Host
s.BaseURL = "https://" + host
if strings.HasSuffix(host, ".onion") || strings.Contains(host, "localhost") {
s.BaseURL = "http://" + host
}
s.FullURL = s.BaseURL + h.r.RequestURI
s.Title = "Imperial Library of Trantor"
s.User = h.sess.User