client

package module
v0.0.0-...-0978c5c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2024 License: MIT Imports: 6 Imported by: 0

README

go-client

Go client library for custom Terraform Provider

Getting Started

Installing

To start using go-client, install Go and go get:

$ go get -u github.com/imseanconroy/go-client

Basic Usage
package main

import (
	"fmt"

	"github.com/imseanconroy/go-client"
)

func main() {
	token := "YOUR_TOKEN"
	client, err := client.NewClient("http://localhost:3000", token)
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	res, _ := client.Get("/tasks")
	fmt.Println(res.Get("0.description").String())
}

This will print something like:

Create go client

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL    string
	HttpClient *http.Client
	Token      string // Bearer token for authentication
}

Client is a simple HTTP client for making requests.

func NewClient

func NewClient(baseURL, token string) (*Client, error)

NewClient creates a new HTTP client instance.

func (*Client) Delete

func (c *Client) Delete(path string) (gjson.Result, error)

Delete performs a DELETE request and returns the response as a gjson.Result.

func (*Client) Do

func (c *Client) Do(method, path string, body interface{}, headers map[string]string) (gjson.Result, error)

Do performs an HTTP request and returns the response as a gjson.Result.

func (*Client) Get

func (c *Client) Get(path string) (gjson.Result, error)

Get performs a GET request and returns the response as a gjson.Result.

func (*Client) Patch

func (c *Client) Patch(path string, body interface{}) (gjson.Result, error)

Patch performs a PATCH request and returns the response as a gjson.Result.

func (*Client) Post

func (c *Client) Post(path string, body interface{}) (gjson.Result, error)

Post performs a POST request and returns the response as a gjson.Result.

func (*Client) Put

func (c *Client) Put(path string, body interface{}) (gjson.Result, error)

Put performs a PUT request and returns the response as a gjson.Result.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL