-
-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This allows self-hosting GoatCounter and reverse proxying it into a subdirectory instead of hosting it on its own subdomain. Fixes #707, #750
- Loading branch information
Showing
59 changed files
with
272 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,7 +140,7 @@ func (h i18n) show(w http.ResponseWriter, r *http.Request) error { | |
|
||
return zhttp.Template(w, "i18n_show.gohtml", struct { | ||
Globals | ||
Base msgfile.File | ||
BaseFile msgfile.File | ||
File msgfile.File | ||
TOMLFile string | ||
FormatLink func(string) string | ||
|
@@ -187,7 +187,7 @@ func (h i18n) new(w http.ResponseWriter, r *http.Request) error { | |
} | ||
|
||
zhttp.Flash(w, "%q added", args.Language) | ||
return zhttp.SeeOther(w, "/i18n") | ||
return SeeOther(w, r, "/i18n") | ||
} | ||
|
||
func (h i18n) save(w http.ResponseWriter, r *http.Request) error { | ||
|
@@ -266,7 +266,7 @@ func (h i18n) set(w http.ResponseWriter, r *http.Request) error { | |
} | ||
|
||
zhttp.Flash(w, "language set to %q", lang) | ||
return zhttp.SeeOther(w, "/i18n") | ||
return SeeOther(w, r, "/i18n") | ||
} | ||
|
||
func (h i18n) submit(w http.ResponseWriter, r *http.Request) error { | ||
|
@@ -294,5 +294,5 @@ func (h i18n) submit(w http.ResponseWriter, r *http.Request) error { | |
}() | ||
|
||
zhttp.Flash(w, "email sent to [email protected]; I'll take a look as soon as possible.") | ||
return zhttp.SeeOther(w, "/i18n/"+file) | ||
return SeeOther(w, r, "/i18n/"+file) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright © Martin Tournoij – This file is part of GoatCounter and published | ||
// under the terms of a slightly modified EUPL v1.2 license, which can be found | ||
// in the LICENSE file or at https://license.goatcounter.com | ||
|
||
package handlers | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
|
||
"zgo.at/goatcounter/v2" | ||
"zgo.at/zhttp" | ||
) | ||
|
||
func MovedPermanently(w http.ResponseWriter, r *http.Request, path string) error { | ||
if path == "" || path[0] != '/' { | ||
panic(fmt.Sprintf("handlers.MovedPermantly: %q does not start with slash", path)) | ||
} | ||
return zhttp.MovedPermanently(w, goatcounter.Config(r.Context()).BasePath+path) | ||
} | ||
|
||
func SeeOther(w http.ResponseWriter, r *http.Request, path string) error { | ||
if path == "" || path[0] != '/' { | ||
panic(fmt.Sprintf("handlers.SeeOther: %q does not start with slash", path)) | ||
} | ||
return zhttp.SeeOther(w, goatcounter.Config(r.Context()).BasePath+path) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.