package response

import (
	"context"
	"encoding/json"
	"net/http"
)

type Response[T any] struct {
	Data T `json:"data"`
}

func RespondJsonSuccess[T any](ctx context.Context, w http.ResponseWriter, data T) {
	setDefaultHeaders(ctx, w.Header())

	w.WriteHeader(http.StatusOK)

	b, _ := json.Marshal(Response[T]{
		Data: data,
	})

	w.Write(b)
}
