httperror

package
v8.0.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProblemBase     = "https://relic.sas.com/"
	ProblemKeyUsage = ProblemBase + "key-usage"
)

Variables

View Source
var (
	ErrForbidden = &Problem{
		Status: http.StatusForbidden,
		Type:   ProblemBase + "forbidden",
	}
	ErrCertificateRequired = &Problem{
		Status: http.StatusUnauthorized,
		Type:   ProblemBase + "certificate-required",
		Detail: "A client certificate must be provided to use this service",
	}
	ErrCertificateNotRecognized = &Problem{
		Status: http.StatusUnauthorized,
		Type:   ProblemBase + "certificate-not-recognized",
		Detail: "The provided client certificate was not recognized or does not grant access to any resources",
	}
	ErrTokenRequired = &Problem{
		Status: http.StatusUnauthorized,
		Type:   ProblemBase + "token-required",
		Detail: "A bearer token or client certificate must be provided to use this service",
	}
	ErrUnknownSignatureType = &Problem{
		Status: http.StatusBadRequest,
		Type:   ProblemBase + "unknown-signature-type",
		Detail: "Unknown signature type specified",
	}
	ErrUnknownDigest = &Problem{
		Status: http.StatusBadRequest,
		Type:   ProblemBase + "unknown-digest-algorithm",
		Detail: "Unknown digest algorithm specified",
	}
)

Functions

func FromResponse

func FromResponse(resp *http.Response) error

func Temporary

func Temporary(err error) bool

Types

type Problem

type Problem struct {
	Status int    `json:"status"`
	Type   string `json:"type"`

	Title    string `json:"title,omitempty"`
	Detail   string `json:"detail,omitempty"`
	Instance string `json:"instance,omitempty"`

	// error-specific
	Param  string   `json:"param,omitempty"`
	Errors []string `json:"errors,omitempty"`
}

Problem implements a RFC 7807 HTTP "problem" response

func BadParameterError

func BadParameterError(err error) Problem

func MissingParameterError

func MissingParameterError(param string) Problem

func NoCertificateError

func NoCertificateError(certType string) Problem

func TokenAuthorizationError

func TokenAuthorizationError(code int, errors []string) Problem

func (Problem) Error

func (e Problem) Error() string

func (Problem) ServeHTTP

func (e Problem) ServeHTTP(rw http.ResponseWriter, req *http.Request)

func (Problem) Temporary

func (e Problem) Temporary() bool

type ResponseError

type ResponseError struct {
	Method     string
	URL        string
	Status     string
	StatusCode int
	BodyText   string
}

func (ResponseError) Error

func (e ResponseError) Error() string

func (ResponseError) Temporary

func (e ResponseError) Temporary() bool

Jump to

Keyboard shortcuts

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