Documentation ¶
Overview ¶
This package collects types that are common to both wfe and wfe2.
Index ¶
- func GetClientAddr(r *http.Request) string
- func KeyTypeToString(pub crypto.PublicKey) string
- func LoadJWK(filename string) (*jose.JSONWebKey, error)
- func NewServer(listenAddr string, handler http.Handler, logger blog.Logger) http.Server
- func ProblemDetailsForError(err error, msg string) *probs.ProblemDetails
- func RelativeEndpoint(request *http.Request, endpoint string) string
- func SendError(log blog.Logger, response http.ResponseWriter, logEvent *RequestEvent, ...)
- type RequestEvent
- type TopHandler
- type WFEHandlerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetClientAddr ¶
GetClientAddr returns a comma-separated list of HTTP clients involved in making this request, starting with the original requester and ending with the remote end of our TCP connection (which is typically our own proxy).
func KeyTypeToString ¶
func NewServer ¶
NewServer returns an http.Server which will listen on the given address, when started, for each path in the handler. Errors are sent to the given logger.
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 ¶
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, 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 the RFC8555 namespace.
- Sends an HTTP response containing the error and an error code to the user.
The internal error (ierr) may be nil if no information beyond the ProblemDetails is needed for internal debugging.
Types ¶
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"` UserAgent string `json:"ua,omitempty"` // Origin is sent by the browser from XHR-based clients. Origin 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 there is a single relevant name, for instance // in an authorization or challenge request. DNSName string `json:",omitempty"` // The set of DNS names, if there are potentially multiple relevant // names, for instance in a new-order, finalize, or revoke request. DNSNames []string `json:",omitempty"` // For challenge POSTs, the challenge type. ChallengeType string `json:",omitempty"` // contains filtered or unexported fields }
RequestEvent is a structured record of the metadata we care about for a single web request. It is generated when a request is received, passed to the request handler which can populate its fields as appropriate, and then logged when the request completes.
func (*RequestEvent) AddError ¶
func (e *RequestEvent) AddError(msg string, args ...interface{})
AddError formats the given message with the given args and appends it to the list of internal errors that have occurred as part of handling this event. If the RequestEvent has been suppressed, this un-suppresses it.
func (*RequestEvent) Suppress ¶
func (e *RequestEvent) Suppress()
Suppress causes the RequestEvent to not be logged at all when the request is complete. This is a no-op if an internal error has been added to the event (logging errors takes precedence over suppressing output).
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)