httpmock

package
v0.0.0-...-6207adf Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Taken from GitHub CLI httpmock package MIT License - Copyright (c) 2019 GitHub Inc.

Taken from GitHub CLI httpmock package MIT License - Copyright (c) 2019 GitHub Inc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchAny

func MatchAny(*http.Request) bool

func ScopesResponder

func ScopesResponder(scopes string) func(*http.Request) (*http.Response, error)

Types

type Matcher

type Matcher func(req *http.Request) bool

func REST

func REST(method, p string) Matcher

type Registry

type Registry struct {
	Requests []*http.Request
	// contains filtered or unexported fields
}

func (*Registry) Register

func (r *Registry) Register(m Matcher, resp Responder)

func (*Registry) RoundTrip

func (r *Registry) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip satisfies http.RoundTripper

func (*Registry) Verify

func (r *Registry) Verify(t Testing)

type Responder

type Responder func(req *http.Request) (*http.Response, error)

func FileResponse

func FileResponse(filename string) Responder

func JSONFromFile

func JSONFromFile(filename string) Responder

func JSONFromString

func JSONFromString(body string) Responder

func JSONResponse

func JSONResponse(body interface{}) Responder

func RESTPayload

func RESTPayload(responseStatus int, responseBody string, cb func(payload map[string]interface{})) Responder

func StatusStringResponse

func StatusStringResponse(status int, body string) Responder

func StringResponse

func StringResponse(body string) Responder

func WithHeader

func WithHeader(responder Responder, header string, value string) Responder

type Stub

type Stub struct {
	Matcher   Matcher
	Responder Responder
	// contains filtered or unexported fields
}

type Testing

type Testing interface {
	Errorf(string, ...interface{})
	Helper()
}

Jump to

Keyboard shortcuts

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