web

package
v0.0.0-...-0cb28c9 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2018 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Overview

This package collects types that are common to both wfe and wfe2.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetClientAddr

func GetClientAddr(r *http.Request) string

Comma-separated list of HTTP clients involved in making this request, starting with the original requestor and ending with the remote end of our TCP connection (which is typically our own proxy).

func ProblemDetailsForError

func ProblemDetailsForError(err error, msg string) *probs.ProblemDetails

problemDetailsForError turns an error into a ProblemDetails with the special case of returning the same error back if its already a ProblemDetails. If the error is of an type unknown to ProblemDetailsForError, it will return a ServerInternal ProblemDetails.

func RelativeEndpoint

func RelativeEndpoint(request *http.Request, endpoint string) string

RelativeEndpoint takes a path component of URL and constructs a new URL using the host and port from the request combined the provided path.

func SendError

func SendError(
	log blog.Logger,
	namespace string,
	response http.ResponseWriter,
	logEvent *RequestEvent,
	prob *probs.ProblemDetails,
	ierr error,
)

SendError does a few things that we want for each error response:

  • Adds both the external and the internal error to a RequestEvent.
  • If the ProblemDetails provided is a ServerInternalProblem, audit logs the internal error.
  • Prefixes the Type field of the ProblemDetails with a namespace.
  • Sends an HTTP response containing the error and an error code to the user.

Types

type RequestEvent

type RequestEvent struct {
	RealIP         string    `json:",omitempty"`
	Endpoint       string    `json:",omitempty"`
	Slug           string    `json:",omitempty"`
	Method         string    `json:",omitempty"`
	InternalErrors []string  `json:",omitempty"`
	Error          string    `json:",omitempty"`
	Requester      int64     `json:",omitempty"`
	Contacts       *[]string `json:",omitempty"`
	UserAgent      string    `json:",omitempty"`
	Latency        float64
	Code           int
	Payload        string                 `json:",omitempty"`
	Extra          map[string]interface{} `json:",omitempty"`
}

func (*RequestEvent) AddError

func (e *RequestEvent) AddError(msg string, args ...interface{})

type TopHandler

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

func NewTopHandler

func NewTopHandler(log blog.Logger, wfe wfeHandler) *TopHandler

func (*TopHandler) ServeHTTP

func (th *TopHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type WFEHandlerFunc

type WFEHandlerFunc func(context.Context, *RequestEvent, http.ResponseWriter, *http.Request)

func (WFEHandlerFunc) ServeHTTP

func (f WFEHandlerFunc) ServeHTTP(e *RequestEvent, w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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