Skip to content

Easiest way to handle API request from golang

License

Notifications You must be signed in to change notification settings

andresPirona/ap-request-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table of Contents

README

The easiest way to create request in go

About the project

Request handler go library

Status

Beta

Layout

Install

go get github.com/andresPirona/ap-request-go

Usage

Supported Methods


- GET
- POST

Make Request


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)

}

About

Easiest way to handle API request from golang

Resources

License

Stars

Watchers

Forks

Languages