mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2025-12-31 01:59:39 -05:00
Bumps [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) from 2.17.1 to 2.17.2. - [Release notes](https://github.com/onsi/ginkgo/releases) - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/ginkgo/compare/v2.17.1...v2.17.2) --- updated-dependencies: - dependency-name: github.com/onsi/ginkgo/v2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
60 lines
1.5 KiB
Go
60 lines
1.5 KiB
Go
package ws
|
|
|
|
// RejectOption represents an option used to control the way connection is
|
|
// rejected.
|
|
type RejectOption func(*ConnectionRejectedError)
|
|
|
|
// RejectionReason returns an option that makes connection to be rejected with
|
|
// given reason.
|
|
func RejectionReason(reason string) RejectOption {
|
|
return func(err *ConnectionRejectedError) {
|
|
err.reason = reason
|
|
}
|
|
}
|
|
|
|
// RejectionStatus returns an option that makes connection to be rejected with
|
|
// given HTTP status code.
|
|
func RejectionStatus(code int) RejectOption {
|
|
return func(err *ConnectionRejectedError) {
|
|
err.code = code
|
|
}
|
|
}
|
|
|
|
// RejectionHeader returns an option that makes connection to be rejected with
|
|
// given HTTP headers.
|
|
func RejectionHeader(h HandshakeHeader) RejectOption {
|
|
return func(err *ConnectionRejectedError) {
|
|
err.header = h
|
|
}
|
|
}
|
|
|
|
// RejectConnectionError constructs an error that could be used to control the
|
|
// way handshake is rejected by Upgrader.
|
|
func RejectConnectionError(options ...RejectOption) error {
|
|
err := new(ConnectionRejectedError)
|
|
for _, opt := range options {
|
|
opt(err)
|
|
}
|
|
return err
|
|
}
|
|
|
|
// ConnectionRejectedError represents a rejection of connection during
|
|
// WebSocket handshake error.
|
|
//
|
|
// It can be returned by Upgrader's On* hooks to indicate that WebSocket
|
|
// handshake should be rejected.
|
|
type ConnectionRejectedError struct {
|
|
reason string
|
|
code int
|
|
header HandshakeHeader
|
|
}
|
|
|
|
// Error implements error interface.
|
|
func (r *ConnectionRejectedError) Error() string {
|
|
return r.reason
|
|
}
|
|
|
|
func (r *ConnectionRejectedError) StatusCode() int {
|
|
return r.code
|
|
}
|