Documentation ¶
Overview ¶
This package collects types that are common to both wfe and wfe2.
Index ¶
- func GetClientAddr(r *http.Request) string
- func ProblemDetailsForError(err error, msg string) *probs.ProblemDetails
- func RelativeEndpoint(request *http.Request, endpoint string) string
- func SendError(log blog.Logger, namespace string, response http.ResponseWriter, ...)
- type RequestEvent
- type TopHandler
- type WFEHandlerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetClientAddr ¶
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 ¶
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)