func NewReadHandler(fs *firestore.Client) http.HandlerFunc {
	return func(rw http.ResponseWriter, r *http.Request) {
		id := chi.URLParam(r, "id")

		docref := fs.Collection(WebhookCollection).Doc(id)
		docsnap, err := docref.Get(r.Context())
		if status.Code(err) == codes.NotFound {
			http.Error(rw, "Invalid webhook id; No webhook registered by that id", http.StatusBadRequest)
			return
		} else if err != nil {
			log.Println(err.Error())
			http.Error(rw, "Something went wrong trying to get the webhook", http.StatusInternalServerError)
			return
		}

		var data Webhook
		err = docsnap.DataTo(&data)
		if err != nil {
			log.Println(err.Error())
			http.Error(rw, "Something went wrong trying to read the webhook", http.StatusInternalServerError)
			return
		}

		_ = json.NewEncoder(rw).Encode(&data)
	}
}
// NewReadHandler creates a HttpHandler that reads one webhook from the database and returns it.
NewReadHandler creates a HttpHandler that reads one webhook from the database and returns it.
// NewReadHandler creates a HttpHandler that reads one webhook from the database and returns it .
func NewReadHandler(fs *firestore.Client) http.HandlerFunc {
	return func(rw http.ResponseWriter, r *http.Request) {
		id := chi.URLParam(r, "id")
		docref := fs.Collection(WebhookCollection).Doc(id)
		docsnap, err := docref.Get(r.Context())
		if status.Code(err) == codes.NotFound {
			http.Error(rw, "Invalid webhook id; No webhook registered by that id", http.StatusBadRequest)
			return
		} else if err != nil {
			log.Println(err.Error())
			http.Error(rw, "Something went wrong trying to get the webhook", http.StatusInternalServerError)
			return
		}
		var data Webhook
		err = docsnap.DataTo(&data)
		if err != nil {
			log.Println(err.Error())
			http.Error(rw, "Something went wrong trying to read the webhook", http.StatusInternalServerError)
			return
		}
		_ = json.NewEncoder(rw).Encode(&data)
	}
}
func NewReadHandler ( fs * firestore . Client ) http . HandlerFunc { return func ( rw http . ResponseWriter , r * http . Request ) { id := chi . URLParam ( r , " " ) docref := fs . Collection ( WebhookCollection ) . Doc ( id ) docsnap , err := docref . Get ( r . Context ( ) ) if status . Code ( err ) == codes . NotFound { http . Error ( rw , " " , http . StatusBadRequest ) return } else if err != nil { log . Println ( err . Error ( ) ) http . Error ( rw , " " , http . StatusInternalServerError ) return } var data Webhook err = docsnap . DataTo ( & data ) if err != nil { log . Println ( err . Error ( ) ) http . Error ( rw , " " , http . StatusInternalServerError ) return } _ = json . NewEncoder ( rw ) . Encode ( & data ) } }
NewReadHandler creates a HttpHandler that reads one webhook from the database and returns it.
NewReadHandler creates a HttpHandler that reads one webhook from the database and returns it .