@@ -19,28 +19,28 @@ type SocketHandle func(request Request, conn *WSConn)
1919
2020// HandleOptions describes options for a route
2121type HandleOptions struct {
22- // AuthenticateMethod method called to determine if a request is properly authenticated or not.
23- // Optional - Omit this entirely if no authentication is needed for the request.
24- // Return nil to signal an unauthenticated request, which will be rejected.
25- // Objects returned will be passed to the handle as the UserData object.
22+ // AuthenticateMethod method called to determine if a request is properly authenticated or not. If a method is
23+ // provided, then it is called for each incoming request. The value returned by this method is passed as the
24+ // UserData field of a [web.Request]. Returning nil signals an unauthenticated request, which will be handled by
25+ // the UnauthorizedMethod (if provided) or a default handle. If the AuthenticateMethod is not provided, then the
26+ // UserData field is nil.
2627 AuthenticateMethod func (request * http.Request ) interface {}
2728 // PreHandle is an optional method that is called immediately upon receiving the HTTP request, before authentication
2829 // and before rate limit checks. This method allows servers to provide early handling of a request before any
2930 // processing happens.
3031 //
31- // The value of the error is not used, only if an error or nil was returned . If an error is returned then no more
32- // processing is performed. It is assumed that a response will have been written to w.
32+ // The returned error is only used as a nil check, the value of any error isn't used . If an error is returned then
33+ // no more processing is performed. It is assumed that a response will have been written to w.
3334 //
3435 // If nil is returned then the request will continue normally, no status should have been written to w. Any headers
3536 // added may be overwritten by the handle.
3637 PreHandle func (w http.ResponseWriter , request * http.Request ) error
37- // UnauthorizedMethod method called when an unauthenticated request occurs ( AuthenticateMethod returned nil)
38- // to customize the response seen by the user.
39- // Optional - Omit this to have a default response .
38+ // UnauthorizedMethod method called when an unauthenticated request occurs, i.e. AuthenticateMethod returned nil,
39+ // which allows you to customize the response seen by the user.
40+ // If omitted, a default handle is used .
4041 UnauthorizedMethod func (w http.ResponseWriter , request * http.Request )
41- // MaxBodyLength defines the maximum length accepted for any HTTP request body. Requests that
42- // exceed this limit will receive a 413 Payload Too Large response.
43- // The default value of 0 will not reject requests with large bodies.
42+ // MaxBodyLength defines the maximum length accepted for any HTTP request body. Requests that exceed this limit will
43+ // receive a "413 Payload Too Large" response. The default value of 0 will not reject requests with large bodies.
4444 MaxBodyLength uint64
4545 // DontLogRequests if true then requests to this handle are not logged
4646 DontLogRequests bool
0 commit comments