all repos — honk @ 6ee07c9220079022bb9bad6666e1a7be5642062d

my fork of honk

u
Anirudh Oppiliappan x@icyphox.sh
Sun, 24 Sep 2023 10:54:56 +0300
commit

6ee07c9220079022bb9bad6666e1a7be5642062d

parent

ca80bc9b156c05c19933488c8f17e1e07822e314

2 files changed, 11 insertions(+), 14 deletions(-)

jump to
M masto.gomasto.go

@@ -4,15 +4,9 @@ import (

"crypto/rand" "fmt" "net/http" - "runtime" "humungus.tedunangst.com/r/webs/junk" ) - -func gf() { - pc, _, _, _ := runtime.Caller(1) - fmt.Printf("%s\n", runtime.FuncForPC(pc).Name()) -} func badjunk(rw http.ResponseWriter, j junk.Junk, path string) { elog.Printf("%s: bad junk: %s", path, j.ToString())

@@ -21,7 +15,6 @@ }

// https://docs.joinmastodon.org/methods/apps/#create func apiapps(rw http.ResponseWriter, r *http.Request) { - gf() dlog.Println(r.URL.String()) if err := r.ParseForm(); err != nil { http.Error(rw, "invalid input", http.StatusUnprocessableEntity)

@@ -50,6 +43,8 @@ j["client_id"] = clientID

j["client_secret"] = clientSecret j["vapid_key"] = vapidKey + fmt.Println(j.ToString()) + rw.WriteHeader(http.StatusOK) rw.Write(j.ToBytes()) }

@@ -62,14 +57,12 @@ }

// https://docs.joinmastodon.org/methods/oauth/#authorize func oauthorize(rw http.ResponseWriter, r *http.Request) { - gf() dlog.Println("oauthorizing!") dlog.Println(r.URL.String) } // https://docs.joinmastodon.org/methods/instance/#v2 func instance(rw http.ResponseWriter, r *http.Request) { - gf() dlog.Println(r.URL.String) j := junk.New()
M web.goweb.go

@@ -2982,11 +2982,15 @@ loggedin.HandleFunc("/emus", showemus)

loggedin.Handle("/submithonker", login.CSRFWrap("submithonker", http.HandlerFunc(websubmithonker))) // mastoshit - getters.Use(logit) - getters.HandleFunc("/oauth/authorize", oauthorize) - getters.HandleFunc("/api/v1/instance", instance) - posters.Use(logit) - posters.HandleFunc("/api/v1/apps", apiapps) + mastopost := mux.Methods("POST").Subrouter() + mastoget := mux.Methods("GET").Subrouter() + + mastoget.Use(logit) + mastoget.HandleFunc("/oauth/authorize", oauthorize) + mastoget.HandleFunc("/api/v1/instance", instance) + + mastopost.Use(logit) + mastopost.HandleFunc("/api/v1/apps", apiapps) err = http.Serve(listener, mux) if err != nil {