all repos — breadsite @ c79ed8de553af34d5f5f0e128e375d8eca8f0518

Unnamed repository; edit this file 'description' to name the repository.

backend/snoot.go (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
package main

import (
	"fmt"
	"net/http"
)

type boopCache struct {
	boops int
}

var boopCounter boopCache

func boopHandler(w http.ResponseWriter, r *http.Request) {
	w.Header().Add("Access-Control-Allow-Origin", "*")
	w.Header().Add("Access-Control-Allow-Headers", "*")
	if r.Method == "POST" {
		boopCounter.boops += 1
	}
	fmt.Fprintf(w, `%v`, boopCounter.boops)
}