all repos — honk @ 6a0a619578417d4ead836d9a614cbc0bd1f4b989

my fork of honk

u
Anirudh Oppiliappan x@icyphox.sh
Tue, 26 Sep 2023 20:16:53 +0300
commit

6a0a619578417d4ead836d9a614cbc0bd1f4b989

parent

31c3a5315b90b6e3563778c23ec4dd3f62800926

1 files changed, 0 insertions(+), 40 deletions(-)

jump to
M masto.gomasto.go

@@ -1,47 +1,13 @@

package main import ( - "bytes" - "crypto/rand" "fmt" "net/http" - "time" "humungus.tedunangst.com/r/webs/junk" "humungus.tedunangst.com/r/webs/login" ) -type NotResponseWriter struct { - body bytes.Buffer - header http.Header -} - -func (w NotResponseWriter) Header() http.Header { - return w.header -} - -func (w NotResponseWriter) Write(b []byte) (int, error) { - return w.body.Write(b) -} - -func (w NotResponseWriter) WriteHeader(statusCode int) {} - -func snowflake() uint64 { - ts := time.Now() - return uint64(uint64(ts.UnixNano()/int64(time.Millisecond))<<16 | uint64(time.Now().Nanosecond()&0xffff)) -} - -func badjunk(rw http.ResponseWriter, j junk.Junk, path string) { - elog.Printf("%s: bad junk: %s", path, j.ToString()) - http.Error(rw, fmt.Sprintf("%s: bad junk", path), http.StatusBadRequest) -} - -func goodjunk(rw http.ResponseWriter, j junk.Junk) { - rw.WriteHeader(http.StatusOK) - rw.Header().Set("Content-Type", "application/json; charset=utf-8") - rw.Write(j.ToBytes()) -} - func showoauthlogin(rw http.ResponseWriter, r *http.Request) { templinfo := make(map[string]interface{}) templinfo = getInfo(r)

@@ -83,12 +49,6 @@ j["vapid_key"] = vapidKey

fmt.Println(j.ToString()) goodjunk(rw, j) -} - -func tokengen() string { - b := make([]byte, 32) - rand.Read(b) - return fmt.Sprintf("%x", b) } // https://docs.joinmastodon.org/methods/oauth/#authorize