transport

package module
v0.0.0-...-24d390e Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2018 License: MIT Imports: 1 Imported by: 1

README

basicauth-transport

A simple transport to wrap other transport to add basic auth to request.

Usage

package main

import (
	"github.com/ArthurHlt/basicauth-transport"
	"net/http"
)

func main() {
	
	http.DefaultClient.Transport = transport.NewDefaultBasicAuthTransport("username", "password")
	
	// with  a custom transport
	http.DefaultClient.Transport = transport.NewBasicAuthTransport(
		"username", 
		"password",
		&http.Transport{})
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicAuthTransport

type BasicAuthTransport struct {
	Username      string
	Password      string
	WrapTransport http.RoundTripper
}

func NewBasicAuthTransport

func NewBasicAuthTransport(username, password string, transport http.RoundTripper) *BasicAuthTransport

func NewDefaultBasicAuthTransport

func NewDefaultBasicAuthTransport(username, password string) *BasicAuthTransport

func (BasicAuthTransport) RoundTrip

func (t BasicAuthTransport) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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