forked from joejulian/gio
website: add shortcuts for issues, commits and patches
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -11,6 +11,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
http.HandleFunc("/issue/", issueHandler)
|
||||||
|
http.HandleFunc("/commit/", commitHandler)
|
||||||
|
http.HandleFunc("/patches/", patchesHandler)
|
||||||
http.HandleFunc("/", vanityHandler)
|
http.HandleFunc("/", vanityHandler)
|
||||||
|
|
||||||
port := os.Getenv("PORT")
|
port := os.Getenv("PORT")
|
||||||
@@ -21,6 +24,33 @@ func main() {
|
|||||||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil))
|
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func patchesHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
p := r.URL.Path
|
||||||
|
const pref = "/patches"
|
||||||
|
url := "https://lists.sr.ht/~eliasnaur/gio/patches" + p[len(pref):]
|
||||||
|
http.Redirect(w, r, url, http.StatusFound)
|
||||||
|
}
|
||||||
|
|
||||||
|
func issueHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
p := r.URL.Path
|
||||||
|
const pref = "/issue"
|
||||||
|
url := "https://todo.sr.ht/~eliasnaur/gio" + p[len(pref):]
|
||||||
|
http.Redirect(w, r, url, http.StatusFound)
|
||||||
|
}
|
||||||
|
|
||||||
|
func commitHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
p := r.URL.Path
|
||||||
|
const pref = "/commit"
|
||||||
|
commit := p[len(pref):]
|
||||||
|
var url string
|
||||||
|
if commit == "/" {
|
||||||
|
url = "https://git.sr.ht/~eliasnaur/gio/log"
|
||||||
|
} else {
|
||||||
|
url = "https://git.sr.ht/~eliasnaur/gio/commit" + commit
|
||||||
|
}
|
||||||
|
http.Redirect(w, r, url, http.StatusFound)
|
||||||
|
}
|
||||||
|
|
||||||
// vanityHandler serves git location meta headers for the go tool.
|
// vanityHandler serves git location meta headers for the go tool.
|
||||||
func vanityHandler(w http.ResponseWriter, r *http.Request) {
|
func vanityHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
if www := "www."; strings.HasPrefix(r.URL.Host, www) {
|
if www := "www."; strings.HasPrefix(r.URL.Host, www) {
|
||||||
|
|||||||
Reference in New Issue
Block a user