context: implement a spy response writer to check if anything is written

This commit is contained in:
2024-09-21 20:46:07 +02:00
parent c5582275e7
commit 7a32f26bd5
2 changed files with 46 additions and 18 deletions

View File

@ -3,6 +3,7 @@ package context
import (
"context"
"fmt"
"log"
"net/http"
)
@ -12,7 +13,11 @@ type Store interface {
func Server(store Store) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
data, _ := store.Fetch(r.Context())
data, err := store.Fetch(r.Context())
if err != nil {
log.Println(err)
return
}
fmt.Fprint(w, data)
}
}