feat: login service and implement database storage
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user