Strangely http POST/GET request in my code is returning empty JSON (for GET) or adding empty struct ( for POST) Here is snip of code
package main
import (
"fmt"
"net/http"
"github.com/gin-gonic/gin"
)
type employee struct {
id int64 `json:"id" binding:"required"`
}
var all_employee = []employee{
{id: 1},
}
func getEmployees(context *gin.Context) {
context.IndentedJSON(http.StatusOK, all_employee)
return
}
func main() {
router := gin.Default()
router.GET("/allemployees", getEmployees)
}
Here is curl output
curl http://localhost:9099/allemployees
[ {} ]