boulder: github.com/letsencrypt/boulder/web Index | Files

package web

import "github.com/letsencrypt/boulder/web"

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

Index

Package Files

context.go docs.go jwk.go probs.go relative.go send_error.go

func GetClientAddr Uses

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 LoadJWK Uses

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

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

func ProblemDetailsForError Uses

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 Uses

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 Uses

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 Uses

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 Uses

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

type TopHandler Uses

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

func NewTopHandler Uses

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

func (*TopHandler) ServeHTTP Uses

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

type WFEHandlerFunc Uses

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

func (WFEHandlerFunc) ServeHTTP Uses

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

Package web imports 16 packages (graph) and is imported by 23 packages. Updated 2019-11-14. Refresh now. Tools for package owners.