Back to

package web

v0.0.0 (71df093)
Latest Go to latest
Published: 3 days ago | License: MPL-2.0 | Module:


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


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 KeyTypeToString

func KeyTypeToString(pub crypto.PublicKey) string

func LoadJWK

func LoadJWK(filename string) (*jose.JSONWebKey, error)

LoadJWK loads a JSON encoded JWK specified by filename or returns an error

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.

type RequestEvent

type RequestEvent struct {
	// These fields are not rendered in JSON; instead, they are rendered
	// whitespace-separated ahead of the JSON. This saves bytes in the logs since
	// we don't have to include field names, quotes, or commas -- all of these
	// fields are known to not include whitespace.
	Method    string  `json:"-"`
	Endpoint  string  `json:"-"`
	Requester int64   `json:"-"`
	Code      int     `json:"-"`
	Latency   float64 `json:"-"`
	RealIP    string  `json:"-"`

	Slug           string   `json:",omitempty"`
	InternalErrors []string `json:",omitempty"`
	Error          string   `json:",omitempty"`
	Contacts       []string `json:",omitempty"`
	UserAgent      string   `json:"ua,omitempty"`
	// Origin is sent by the browser from XHR-based clients.
	Origin  string                 `json:",omitempty"`
	Payload string                 `json:",omitempty"`
	Extra   map[string]interface{} `json:",omitempty"`

	// For endpoints that create objects, the ID of the newly created object.
	Created string `json:",omitempty"`

	// For challenge and authorization GETs and POSTs:
	// the status of the authorization at the time the request began.
	Status string `json:",omitempty"`
	// The DNS name, if applicable
	DNSName string `json:",omitempty"`

	// For challenge POSTs, the challenge type.
	ChallengeType string `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)
Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier