problem

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2024 License: MIT Imports: 7 Imported by: 0

README

problem

An RFC 7807 compatible error library for Go.

Overview

This library provides a structured way to handle HTTP errors in Go applications, compatible with RFC 7807. It defines custom error types for various HTTP status codes and provides methods to create and manipulate these errors.

Features

  • Custom error types for HTTP status codes.
  • Methods to create new errors with messages.
  • JSON serialization of errors.
  • slog Logging support.

Installation

To install the library, run:

go get -u github.com/bnprtr/problem

Usage

To use problem, you should define error constants for the types of your errors. The constant should by typed as one of problem's Status types:

package main

import (
  "errors"
  "net/http"
  "github.com/bnprtr/problem"
)

const (
  InvalidInput problem.StatusBadRequest = "invalid input"
  InvalidJSON problem.StatusBadRequest = "invalid json"

  // always capture stack trace on all InternalServerErrors
  InternalServerError problem.StackTraced[problem.StatusInternalServerError] = "internal server error"
)

type Request struct {
 Name string
 URL  string
}

func MyHandler(w http.ResponseWriter, r *http.Request) {
 if err := handle(r); err != nil {
  var statusCode problem.StatusCode
  if !errors.As(err, &statusCode) {
   // unknown error!
   err = InternalServerError.New("unexpected error occurred.").AddInternalErrors(err)
   statusCode = InternalServerError.StatusCode()
  }
  w.Header().Set("Content-Type", "application/problem+json")
  w.WriteHeader(int(statusCode))
  json.NewEncoder(w).Encode(err)
 }
}

func (r *http.Request) error {
 var req Request
 if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
  return InvalidJSON.New(err.Error()).AddInternalErrors(err)
 }

 if err := validate(req); err != nil {
  panic(err)
 }
 return nil
}

func validate(r Request) error {
 err := InvalidInput.New("request input failed validation")
 var failed bool
 if r.Name == "" {
  failed = true
  err = err.AddDetails(problem.NewFieldDetail("Name", r.Name, "required"))
 }
 if r.URL != "" {
  _, e := url.Parse(r.URL)
  if e != nil {
   failed = true
   err = err.AddInternalErrors(e)
   err = err.AddDetails(problem.NewFieldDetail("URL", r.URL, e.Error()))
  }
 }
 if failed {
  return err
 }
 return nil
}

Documentation

Overview

Example
package main

import (
	"encoding/json"
	"errors"
	"log/slog"
	"net/http"

	"github.com/bnprtr/problem"
)

func main() {
	_ = http.ListenAndServe(":8080", http.HandlerFunc(MyHandler))
}

func MyHandler(w http.ResponseWriter, r *http.Request) {
	if err := handle(r); err != nil {
		var statusCode problem.StatusCode
		if !errors.As(err, &statusCode) {
			// unknown error!
			err = InternalServerError.New("unexpected error occurred.").AddInternalErrors(err)
			statusCode = InternalServerError.StatusCode()
		}
		switch {
		case statusCode < 500:
			slog.WarnContext(r.Context(), "handler returned error", "error", err)
		default:
			slog.ErrorContext(r.Context(), "handler returned error", "error", err)
		}
		w.Header().Set("Content-Type", "application/problem+json")
		w.WriteHeader(int(statusCode))
		_ = json.NewEncoder(w).Encode(err)
	}
}

func handle(r *http.Request) error {
	var req Request
	if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
		return InvalidJSON.New(err.Error()).AddInternalErrors(err).Stack()
	}

	if err := validate(req); err != nil {
		panic(err)
	}
	return nil
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Details

type Details []any

func (Details) Error

func (s Details) Error() string

type Error

type Error struct {
	// Title is a short, matchable string of the error. It is recommended for the title to be human readable and
	// representative of the error condition.
	//
	// example: "Missing Required Field"
	//
	// Titles are best defined as constants in your codebase to ensure consistency and to allow for easy matching.
	// Use the "Status" types to map the title to an HTTP status code.
	//
	// example: const MissingFieldRequired problem.HTTPStatusBadRequest = "Missing Required Field"
	//
	// This allows for easy matching of error types or status codes in your codebase:
	//
	//   // check if the error is a specific title
	//   if errors.Is(err, MissingFieldRequired) {
	// 		// handle missing field error
	//   }
	//
	//   // check if the error is a specific status code
	//   if errors.Is(err, problem.HTTPStatusBadRequest) {
	// 		// handle bad request error
	//   }
	//
	//   // get the status code of the error
	//   var status problem.StatusCode
	//   if errors.As(err, &status) {
	//   	// handle status code
	//   }
	//
	//   // get the title of the error
	//   var title problem.Title
	//   if errors.As(err, &title) {
	//   	// handle title
	//   }
	//
	Title string `json:"title"`

	// Message is a human-readable explanation specific to this occurrence of the problem. It is recommended to be
	// short and to the point. It is not intended to be a complete description of the error. The message may
	// displayed on the client it so it should not be overly technical. Technical details for debugging or advanced
	// behvaior response should be added to the Details instead.
	// example: "The request body is missing the required field 'name'."
	Message string `json:"message"`

	// Stacktrace is the stacktrace of the error. It is not intended to be exposed outside of the closed system.
	// The stacktrace is stored for internal use and debugging. The stacktrace is not included in the JSON
	// serialization of the error. The stacktrace is not unwrapped when the error is unwrapped.
	// The stacktrace is not automatically captured. It must be manually set by invoking the Stack() method
	// when the error is created.
	Stacktrace string `json:"-"`

	// Internal is a list of internal errors that caused the problem. These errors are not intended to be exposed
	// outside of the closed system. They are stored for internal use and debugging. The internal errors are
	// unwrapped when the error is unwrapped, allowing for easy matching and logging.
	Internal []error `json:"-"`

	// Details is a list of additional details that may be useful for debugging or advanced behavior. The details
	// are intended to be exposed externally and are included in the JSON serialization of the error.
	// It is recommended to use a struct for the details to allow for easy serialization and deserialization.
	// It is also recommended to use standard format for different types of details. This package provides a
	// standard FieldDetail type for common field errors.
	Details []any `json:"details"`

	// HttpStatusCode is the HTTP status code that should be returned with the error. The status code is used to
	// determine the response status code when the error is returned to the client. The status code is unwrapped
	// when the error is unwrapped, allowing for simple matching and serialization of errors returned in a centrale
	// error handler in HTTP handlers.
	//
	// example:
	//
	//   var statusCode problem.StatusCode
	//   if !errors.As(err, &statusCode) {
	//   	// unknown error, return internal server error
	//   	statusCode = problem.HTTPStatusInternalServerError
	//      // ovveride the error and wrap in an internal server error
	//  	err = problem.New(problem.StatusInternalServerError("Internal Server Error")).WithInternalErrors(err)
	//   }
	//	 w.Header().Set("Content-Type", "application/problem+json")
	//	 w.WriteHeader(int(statusCode))
	//	 json.NewEncoder(w).Encode(err)
	HttpStatusCode StatusCode `json:"statusCode"`
}

Error represents a problem as defined by RFC 7807. It is go error value that can hold internal errors. Internal errors, the Title, and the HTTP Status Code are unwrapped allowing for error matching using errors.Is and errors.As. The Error properties can be set using a builder pattern:

err := problem.New("title").WithMessage("message").WithDetails("details").WithInternalErrors(internalErrs...)

The error is also a loggable value using slog:

slog.InfoContext(ctx, "something bad happened", "error", err)

JSON Serialization of the error will not render out the internal errors. The internal errors are only stored for internal use and are not intended to be exposed outside of the closed system. External details should be added as Details of the problem.

Example
package main

import (
	"fmt"
	"net/url"

	"github.com/bnprtr/problem"
)

const (
	InvalidJSON  problem.StatusBadRequest = "invalid json"
	InvalidInput problem.StatusBadRequest = "invalid input"

	// InternalServerError is essentially an unhandled error, always capture the stack trace for debugging purposes.
	InternalServerError problem.StackTraced[problem.StatusInternalServerError] = "internal server error"
)

type Request struct {
	Name string
	URL  string
}

func main() {
	request := Request{
		Name: "",
		URL:  "%+0",
	}
	if err := validate(request); err != nil {
		fmt.Println(err.Error())
	}
}

func validate(r Request) error {
	err := InvalidInput.New("request input failed validation")
	var failed bool
	if r.Name == "" {
		failed = true
		err = err.AddDetails(problem.NewFieldDetail("Name", r.Name, "required"))
	}
	if r.URL != "" {
		_, e := url.Parse(r.URL)
		if e != nil {
			failed = true
			err = err.AddInternalErrors(e)
			err = err.AddDetails(problem.NewFieldDetail("URL", r.URL, e.Error()))
		}
	}
	if failed {
		return err
	}
	return nil
}
Output:

{"title":"invalid input","message":"request input failed validation","internalError":[{"Op":"parse","URL":"%+0","Err":"%+0"}],"details":[{"field":"Name","value":"","reason":"required"},{"field":"URL","value":"%+0","reason":"parse \"%+0\": invalid URL escape \"%+0\""}]}

func New

func New[T ErrorTitle](title T) Error

New creates a new Error with the given title.

func (Error) AddDetails

func (e Error) AddDetails(details ...any) Error

AddDetails adds additional details to the error. The details are intended to be exposed externally and are included in the JSON serialization of the error.

func (Error) AddInternalErrors

func (e Error) AddInternalErrors(errors ...error) Error

AddInternalErrors adds internal errors to the error. The internal errors are not intended to be exposed outside of the closed system. They are stored for internal use and debugging. The internal errors are unwrapped when the error is unwrapped, allowing for easy matching and logging.

func (Error) Error

func (e Error) Error() string

Error returns a string representation of the Error. It is rendered as a JSON object, including all internal errors.

func (Error) LogValue

func (e Error) LogValue() slog.Value

func (Error) SetMessage

func (e Error) SetMessage(message string) Error

SetMessage overrides the message of the error. The message is a human-readable explanation specific to this occurrence

func (Error) SetTitle

func (e Error) SetTitle(title string) Error

SetTitle overrides the title of the error. This is not recommended as the title should be a constant in your codebase.

func (Error) Stack

func (e Error) Stack() Error

Stack captures the stack trace from the point where it is called and stores it in the Stacktrace property.

func (Error) Unwrap

func (e Error) Unwrap() []error

type ErrorTitle

type ErrorTitle interface {
	~string
	error
	StatusCode() StatusCode
	New(string) Error
}

type FieldDetail

type FieldDetail struct {
	Field  string `json:"field"`
	Value  string `json:"value"`
	Reason string `json:"reason"`
}

func NewFieldDetail

func NewFieldDetail(field, value, reason string) FieldDetail

func (FieldDetail) Error

func (e FieldDetail) Error() string

type StackTraced

type StackTraced[T ErrorTitle] string

StackTraced can be used to extend the Status Title types so the Title.New() always captures the stack trace. Establish your title consts with StackTraced[ErrorTitle] and every New calls from the title will automatically capture the stacktrace.

func (StackTraced[T]) Error

func (e StackTraced[T]) Error() string

func (StackTraced[T]) New

func (e StackTraced[T]) New(message string) Error

func (StackTraced[T]) StatusCode

func (e StackTraced[T]) StatusCode() StatusCode

type StatusBadGateway

type StatusBadGateway string

func (StatusBadGateway) Error

func (e StatusBadGateway) Error() string

func (StatusBadGateway) New

func (e StatusBadGateway) New(message string) Error

func (StatusBadGateway) StatusCode

func (e StatusBadGateway) StatusCode() StatusCode

type StatusBadRequest

type StatusBadRequest string

400 level

func (StatusBadRequest) Error

func (e StatusBadRequest) Error() string

func (StatusBadRequest) New

func (e StatusBadRequest) New(message string) Error

func (StatusBadRequest) StatusCode

func (e StatusBadRequest) StatusCode() StatusCode

type StatusCode

type StatusCode int

func (StatusCode) Error

func (s StatusCode) Error() string

type StatusConflict

type StatusConflict string

func (StatusConflict) Error

func (e StatusConflict) Error() string

func (StatusConflict) New

func (e StatusConflict) New(message string) Error

func (StatusConflict) StatusCode

func (e StatusConflict) StatusCode() StatusCode

type StatusExpectationFailed

type StatusExpectationFailed string

func (StatusExpectationFailed) Error

func (e StatusExpectationFailed) Error() string

func (StatusExpectationFailed) New

func (e StatusExpectationFailed) New(message string) Error

func (StatusExpectationFailed) StatusCode

func (e StatusExpectationFailed) StatusCode() StatusCode

type StatusFailedDependency

type StatusFailedDependency string

func (StatusFailedDependency) Error

func (e StatusFailedDependency) Error() string

func (StatusFailedDependency) New

func (e StatusFailedDependency) New(message string) Error

func (StatusFailedDependency) StatusCode

func (e StatusFailedDependency) StatusCode() StatusCode

type StatusForbidden

type StatusForbidden string

func (StatusForbidden) Error

func (e StatusForbidden) Error() string

func (StatusForbidden) New

func (e StatusForbidden) New(message string) Error

func (StatusForbidden) StatusCode

func (e StatusForbidden) StatusCode() StatusCode

type StatusFound

type StatusFound string

func (StatusFound) Error

func (e StatusFound) Error() string

func (StatusFound) New

func (e StatusFound) New(message string) Error

func (StatusFound) StatusCode

func (e StatusFound) StatusCode() StatusCode

type StatusGatewayTimeout

type StatusGatewayTimeout string

func (StatusGatewayTimeout) Error

func (e StatusGatewayTimeout) Error() string

func (StatusGatewayTimeout) New

func (e StatusGatewayTimeout) New(message string) Error

func (StatusGatewayTimeout) StatusCode

func (e StatusGatewayTimeout) StatusCode() StatusCode

type StatusGone

type StatusGone string

func (StatusGone) Error

func (e StatusGone) Error() string

func (StatusGone) New

func (e StatusGone) New(message string) Error

func (StatusGone) StatusCode

func (e StatusGone) StatusCode() StatusCode

type StatusHTTPVersionNotSupported

type StatusHTTPVersionNotSupported string

func (StatusHTTPVersionNotSupported) Error

func (StatusHTTPVersionNotSupported) New

func (StatusHTTPVersionNotSupported) StatusCode

type StatusInsufficientStorage

type StatusInsufficientStorage string

func (StatusInsufficientStorage) Error

func (StatusInsufficientStorage) New

func (e StatusInsufficientStorage) New(message string) Error

func (StatusInsufficientStorage) StatusCode

func (e StatusInsufficientStorage) StatusCode() StatusCode

type StatusInternalServerError

type StatusInternalServerError string

500 level

func (StatusInternalServerError) Error

func (StatusInternalServerError) New

func (e StatusInternalServerError) New(message string) Error

func (StatusInternalServerError) StatusCode

func (e StatusInternalServerError) StatusCode() StatusCode

type StatusLengthRequired

type StatusLengthRequired string

func (StatusLengthRequired) Error

func (e StatusLengthRequired) Error() string

func (StatusLengthRequired) New

func (e StatusLengthRequired) New(message string) Error

func (StatusLengthRequired) StatusCode

func (e StatusLengthRequired) StatusCode() StatusCode

type StatusLocked

type StatusLocked string

func (StatusLocked) Error

func (e StatusLocked) Error() string

func (StatusLocked) New

func (e StatusLocked) New(message string) Error

func (StatusLocked) StatusCode

func (e StatusLocked) StatusCode() StatusCode

type StatusLoopDetected

type StatusLoopDetected string

func (StatusLoopDetected) Error

func (e StatusLoopDetected) Error() string

func (StatusLoopDetected) New

func (e StatusLoopDetected) New(message string) Error

func (StatusLoopDetected) StatusCode

func (e StatusLoopDetected) StatusCode() StatusCode

type StatusMethodNotAllowed

type StatusMethodNotAllowed string

func (StatusMethodNotAllowed) Error

func (e StatusMethodNotAllowed) Error() string

func (StatusMethodNotAllowed) New

func (e StatusMethodNotAllowed) New(message string) Error

func (StatusMethodNotAllowed) StatusCode

func (e StatusMethodNotAllowed) StatusCode() StatusCode

type StatusMisdirectedRequest

type StatusMisdirectedRequest string

func (StatusMisdirectedRequest) Error

func (e StatusMisdirectedRequest) Error() string

func (StatusMisdirectedRequest) New

func (e StatusMisdirectedRequest) New(message string) Error

func (StatusMisdirectedRequest) StatusCode

func (e StatusMisdirectedRequest) StatusCode() StatusCode

type StatusMovedPermanently

type StatusMovedPermanently string

func (StatusMovedPermanently) Error

func (e StatusMovedPermanently) Error() string

func (StatusMovedPermanently) New

func (e StatusMovedPermanently) New(message string) Error

func (StatusMovedPermanently) StatusCode

func (e StatusMovedPermanently) StatusCode() StatusCode

type StatusMultipleChoices

type StatusMultipleChoices string

300 level

func (StatusMultipleChoices) Error

func (e StatusMultipleChoices) Error() string

func (StatusMultipleChoices) New

func (e StatusMultipleChoices) New(message string) Error

func (StatusMultipleChoices) StatusCode

func (e StatusMultipleChoices) StatusCode() StatusCode

type StatusNetworkAuthenticationRequired

type StatusNetworkAuthenticationRequired string

func (StatusNetworkAuthenticationRequired) Error

func (StatusNetworkAuthenticationRequired) New

func (StatusNetworkAuthenticationRequired) StatusCode

type StatusNotAcceptable

type StatusNotAcceptable string

func (StatusNotAcceptable) Error

func (e StatusNotAcceptable) Error() string

func (StatusNotAcceptable) New

func (e StatusNotAcceptable) New(message string) Error

func (StatusNotAcceptable) StatusCode

func (e StatusNotAcceptable) StatusCode() StatusCode

type StatusNotExtended

type StatusNotExtended string

func (StatusNotExtended) Error

func (e StatusNotExtended) Error() string

func (StatusNotExtended) New

func (e StatusNotExtended) New(message string) Error

func (StatusNotExtended) StatusCode

func (e StatusNotExtended) StatusCode() StatusCode

type StatusNotFound

type StatusNotFound string

func (StatusNotFound) Error

func (e StatusNotFound) Error() string

func (StatusNotFound) New

func (e StatusNotFound) New(message string) Error

func (StatusNotFound) StatusCode

func (e StatusNotFound) StatusCode() StatusCode

type StatusNotImplemented

type StatusNotImplemented string

func (StatusNotImplemented) Error

func (e StatusNotImplemented) Error() string

func (StatusNotImplemented) New

func (e StatusNotImplemented) New(message string) Error

func (StatusNotImplemented) StatusCode

func (e StatusNotImplemented) StatusCode() StatusCode

type StatusNotModified

type StatusNotModified string

func (StatusNotModified) Error

func (e StatusNotModified) Error() string

func (StatusNotModified) New

func (e StatusNotModified) New(message string) Error

func (StatusNotModified) StatusCode

func (e StatusNotModified) StatusCode() StatusCode

type StatusPaymentRequired

type StatusPaymentRequired string

func (StatusPaymentRequired) Error

func (e StatusPaymentRequired) Error() string

func (StatusPaymentRequired) New

func (e StatusPaymentRequired) New(message string) Error

func (StatusPaymentRequired) StatusCode

func (e StatusPaymentRequired) StatusCode() StatusCode

type StatusPermanentRedirect

type StatusPermanentRedirect string

func (StatusPermanentRedirect) Error

func (e StatusPermanentRedirect) Error() string

func (StatusPermanentRedirect) New

func (e StatusPermanentRedirect) New(message string) Error

func (StatusPermanentRedirect) StatusCode

func (e StatusPermanentRedirect) StatusCode() StatusCode

type StatusPreconditionFailed

type StatusPreconditionFailed string

func (StatusPreconditionFailed) Error

func (e StatusPreconditionFailed) Error() string

func (StatusPreconditionFailed) New

func (e StatusPreconditionFailed) New(message string) Error

func (StatusPreconditionFailed) StatusCode

func (e StatusPreconditionFailed) StatusCode() StatusCode

type StatusPreconditionRequired

type StatusPreconditionRequired string

func (StatusPreconditionRequired) Error

func (StatusPreconditionRequired) New

func (e StatusPreconditionRequired) New(message string) Error

func (StatusPreconditionRequired) StatusCode

func (e StatusPreconditionRequired) StatusCode() StatusCode

type StatusProxyAuthRequired

type StatusProxyAuthRequired string

func (StatusProxyAuthRequired) Error

func (e StatusProxyAuthRequired) Error() string

func (StatusProxyAuthRequired) New

func (e StatusProxyAuthRequired) New(message string) Error

func (StatusProxyAuthRequired) StatusCode

func (e StatusProxyAuthRequired) StatusCode() StatusCode

type StatusRequestEntityTooLarge

type StatusRequestEntityTooLarge string

func (StatusRequestEntityTooLarge) Error

func (StatusRequestEntityTooLarge) New

func (e StatusRequestEntityTooLarge) New(message string) Error

func (StatusRequestEntityTooLarge) StatusCode

func (e StatusRequestEntityTooLarge) StatusCode() StatusCode

type StatusRequestHeaderFieldsTooLarge

type StatusRequestHeaderFieldsTooLarge string

func (StatusRequestHeaderFieldsTooLarge) Error

func (StatusRequestHeaderFieldsTooLarge) New

func (StatusRequestHeaderFieldsTooLarge) StatusCode

type StatusRequestTimeout

type StatusRequestTimeout string

func (StatusRequestTimeout) Error

func (e StatusRequestTimeout) Error() string

func (StatusRequestTimeout) New

func (e StatusRequestTimeout) New(message string) Error

func (StatusRequestTimeout) StatusCode

func (e StatusRequestTimeout) StatusCode() StatusCode

type StatusRequestURITooLong

type StatusRequestURITooLong string

func (StatusRequestURITooLong) Error

func (e StatusRequestURITooLong) Error() string

func (StatusRequestURITooLong) New

func (e StatusRequestURITooLong) New(message string) Error

func (StatusRequestURITooLong) StatusCode

func (e StatusRequestURITooLong) StatusCode() StatusCode

type StatusRequestedRangeNotSatisfiable

type StatusRequestedRangeNotSatisfiable string

func (StatusRequestedRangeNotSatisfiable) Error

func (StatusRequestedRangeNotSatisfiable) New

func (StatusRequestedRangeNotSatisfiable) StatusCode

type StatusSeeOther

type StatusSeeOther string

func (StatusSeeOther) Error

func (e StatusSeeOther) Error() string

func (StatusSeeOther) New

func (e StatusSeeOther) New(message string) Error

func (StatusSeeOther) StatusCode

func (e StatusSeeOther) StatusCode() StatusCode

type StatusServiceUnavailable

type StatusServiceUnavailable string

func (StatusServiceUnavailable) Error

func (e StatusServiceUnavailable) Error() string

func (StatusServiceUnavailable) New

func (e StatusServiceUnavailable) New(message string) Error

func (StatusServiceUnavailable) StatusCode

func (e StatusServiceUnavailable) StatusCode() StatusCode

type StatusTeapot

type StatusTeapot string

func (StatusTeapot) Error

func (e StatusTeapot) Error() string

func (StatusTeapot) New

func (e StatusTeapot) New(message string) Error

func (StatusTeapot) StatusCode

func (e StatusTeapot) StatusCode() StatusCode

type StatusTemporaryRedirect

type StatusTemporaryRedirect string

func (StatusTemporaryRedirect) Error

func (e StatusTemporaryRedirect) Error() string

func (StatusTemporaryRedirect) New

func (e StatusTemporaryRedirect) New(message string) Error

func (StatusTemporaryRedirect) StatusCode

func (e StatusTemporaryRedirect) StatusCode() StatusCode

type StatusTooEarly

type StatusTooEarly string

func (StatusTooEarly) Error

func (e StatusTooEarly) Error() string

func (StatusTooEarly) New

func (e StatusTooEarly) New(message string) Error

func (StatusTooEarly) StatusCode

func (e StatusTooEarly) StatusCode() StatusCode

type StatusTooManyRequests

type StatusTooManyRequests string

func (StatusTooManyRequests) Error

func (e StatusTooManyRequests) Error() string

func (StatusTooManyRequests) New

func (e StatusTooManyRequests) New(message string) Error

func (StatusTooManyRequests) StatusCode

func (e StatusTooManyRequests) StatusCode() StatusCode

type StatusUnauthorized

type StatusUnauthorized string

func (StatusUnauthorized) Error

func (e StatusUnauthorized) Error() string

func (StatusUnauthorized) New

func (e StatusUnauthorized) New(message string) Error

func (StatusUnauthorized) StatusCode

func (e StatusUnauthorized) StatusCode() StatusCode

type StatusUnavailableForLegalReasons

type StatusUnavailableForLegalReasons string

func (StatusUnavailableForLegalReasons) Error

func (StatusUnavailableForLegalReasons) New

func (StatusUnavailableForLegalReasons) StatusCode

type StatusUnprocessableEntity

type StatusUnprocessableEntity string

func (StatusUnprocessableEntity) Error

func (StatusUnprocessableEntity) New

func (e StatusUnprocessableEntity) New(message string) Error

func (StatusUnprocessableEntity) StatusCode

func (e StatusUnprocessableEntity) StatusCode() StatusCode

type StatusUnsupportedMediaType

type StatusUnsupportedMediaType string

func (StatusUnsupportedMediaType) Error

func (StatusUnsupportedMediaType) New

func (e StatusUnsupportedMediaType) New(message string) Error

func (StatusUnsupportedMediaType) StatusCode

func (e StatusUnsupportedMediaType) StatusCode() StatusCode

type StatusUpgradeRequired

type StatusUpgradeRequired string

func (StatusUpgradeRequired) Error

func (e StatusUpgradeRequired) Error() string

func (StatusUpgradeRequired) New

func (e StatusUpgradeRequired) New(message string) Error

func (StatusUpgradeRequired) StatusCode

func (e StatusUpgradeRequired) StatusCode() StatusCode

type StatusUseProxy

type StatusUseProxy string

func (StatusUseProxy) Error

func (e StatusUseProxy) Error() string

func (StatusUseProxy) New

func (e StatusUseProxy) New(message string) Error

func (StatusUseProxy) StatusCode

func (e StatusUseProxy) StatusCode() StatusCode

type StatusVariantAlsoNegotiates

type StatusVariantAlsoNegotiates string

func (StatusVariantAlsoNegotiates) Error

func (StatusVariantAlsoNegotiates) New

func (e StatusVariantAlsoNegotiates) New(message string) Error

func (StatusVariantAlsoNegotiates) StatusCode

func (e StatusVariantAlsoNegotiates) StatusCode() StatusCode

type Title

type Title string

func (Title) Error

func (t Title) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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