package
0.11.0-alpha
Repository: https://github.com/meowmix1337/go-core.git
Documentation: pkg.go.dev

# README

http util

Provides a utility functions with http responses, etc

Usage

JSONResponse

type User struct {
	ID    int    `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`
}

// Use the JSONResponse function to return the struct as JSON
http_util.JSONResponse(w, http.StatusOK, user)

The output will be:

{
  "id": 1,
  "name": "John Doe",
  "email": "[email protected]"
}

# Functions

JSONResponse writes a JSON response with the provided status code and data.