Table of Contents
The easiest way to create request in go
Request handler go library
Beta
go get github.com/andresPirona/ap-request-go
- GET
- POST
package main
import (
"fmt"
ap_request_go "github.com/andresPirona/ap-request-go"
"github.com/andresPirona/ap-request-go/pkg/app/domain"
"net/http"
)
type EntityResponse struct {
ID string `json:"id"`
Name string `json:"name"`
}
func main() {
var testRequest = domain.Options{
Method: http.MethodGet,
Url: "https://6413050a3b710647375ca7be.mockapi.io/api/v1/users/1",
Body: nil,
Auth: nil,
Headers: nil,
Params: nil,
}
entityResponse, response, err := ap_request_go.NewRequest[EntityResponse](testRequest)
if err != nil {
fmt.Println("error")
}
fmt.Println(response)
fmt.Println(entityResponse)
}