goha

package module
v0.0.0-...-1f87faf Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2018 License: Apache-2.0 Imports: 10 Imported by: 2

README

goha

A simple HTTP client supporting Basic and Digest access authentication.

Installation

go get github.com/FeNoMeNa/goha

Quick Start

package main

import (
	"fmt"

	"github.com/FeNoMeNa/goha"
)

func main() {
	c := goha.NewClient("username", "password")

	resp, err := c.Get("http://localhost:8080/")

	if err != nil {
		return
	}

	fmt.Println(resp.StatusCode)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a wrapper to http.client. It is used as builder to construct the real http client

func NewClient

func NewClient(username, password string) *Client

NewClient creates and initializes a new goha http client that will be able to authorize its requests via Basic / Digest authentication scheme.

func NewClientWithTransport

func NewClientWithTransport(username, password string, transport http.RoundTripper) *Client

NewClient creates a new goha http client with provided http.Transport

func (*Client) Do

func (c *Client) Do(req *http.Request) (resp *http.Response, err error)

func (*Client) Get

func (c *Client) Get(url string) (resp *http.Response, err error)

func (*Client) Head

func (c *Client) Head(url string) (resp *http.Response, err error)

func (*Client) Jar

func (c *Client) Jar(j *cookiejar.Jar) *Client

Jar sets Client.Jar to passed cookiejar.Jar

func (*Client) Post

func (c *Client) Post(url string, bodyType string, body io.Reader) (resp *http.Response, err error)

func (*Client) PostForm

func (c *Client) PostForm(url string, data url.Values) (resp *http.Response, err error)

func (*Client) Timeout

func (c *Client) Timeout(t time.Duration) *Client

Timeout initializes the default timeout of the http client. A Timeout of zero means no timeout.

Jump to

Keyboard shortcuts

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