Further cleanups

This commit is contained in:
Bolke de Bruin 2020-07-20 22:53:15 +02:00
parent 354355e6b0
commit 93b31ec9b6
2 changed files with 0 additions and 62 deletions

View file

@ -1,55 +0,0 @@
package main
import "github.com/bolkedebruin/rdpgw/protocol"
// RejectOption represents an option used to control the way connection is
// rejected.
type RejectOption func(*rejectConnectionError)
// RejectionReason returns an option that makes connection to be rejected with
// given reason.
func RejectionReason(reason string) RejectOption {
return func(err *rejectConnectionError) {
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 *rejectConnectionError) {
err.code = code
}
}
// RejectionHeader returns an option that makes connection to be rejected with
// given HTTP headers.
func RejectionHeader(h protocol.HandshakeHeader) RejectOption {
return func(err *rejectConnectionError) {
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(rejectConnectionError)
for _, opt := range options {
opt(err)
}
return err
}
// rejectConnectionError represents a rejection of upgrade error.
//
// It can be returned by Upgrader's On* hooks to control the way WebSocket
// handshake is rejected.
type rejectConnectionError struct {
reason string
code int
header protocol.HandshakeHeader
}
// Error implements error interface.
func (r *rejectConnectionError) Error() string {
return r.reason
}

View file

@ -5,7 +5,6 @@ import (
"github.com/gorilla/websocket"
"github.com/patrickmn/go-cache"
"github.com/prometheus/client_golang/prometheus"
"io"
"log"
"net/http"
"time"
@ -40,12 +39,6 @@ var (
})
)
// HandshakeHeader is the interface that writes both upgrade request or
// response headers into a given io.Writer.
type HandshakeHeader interface {
io.WriterTo
}
type SessionInfo struct {
ConnId string
CorrelationId string