Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
076d4e0e
Commit
076d4e0e
authored
Mar 28, 2015
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored web socket middleware to return errors
parent
b87e6ccb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
middleware/websockets/websockets.go
middleware/websockets/websockets.go
+5
-5
No files found.
middleware/websockets/websockets.go
View file @
076d4e0e
...
...
@@ -16,7 +16,7 @@ type (
// websocket endpoints.
WebSockets
struct
{
// Next is the next HTTP handler in the chain for when the path doesn't match
Next
http
.
HandlerFunc
Next
middleware
.
HandlerFunc
// Sockets holds all the web socket endpoint configurations
Sockets
[]
WSConfig
...
...
@@ -33,7 +33,7 @@ type (
)
// ServeHTTP converts the HTTP request to a WebSocket connection and serves it up.
func
(
ws
WebSockets
)
ServeHTTP
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
func
(
ws
WebSockets
)
ServeHTTP
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
(
int
,
error
)
{
for
_
,
sockconfig
:=
range
ws
.
Sockets
{
if
middleware
.
Path
(
r
.
URL
.
Path
)
.
Matches
(
sockconfig
.
Path
)
{
socket
:=
WebSocket
{
...
...
@@ -41,12 +41,12 @@ func (ws WebSockets) ServeHTTP(w http.ResponseWriter, r *http.Request) {
Request
:
r
,
}
websocket
.
Handler
(
socket
.
Handle
)
.
ServeHTTP
(
w
,
r
)
return
return
0
,
nil
}
}
// Didn't match a websocket path, so pass-thru
ws
.
Next
(
w
,
r
)
return
ws
.
Next
(
w
,
r
)
}
// New constructs and configures a new websockets middleware instance.
...
...
@@ -115,7 +115,7 @@ func New(c middleware.Controller) (middleware.Middleware, error) {
GatewayInterface
=
envGatewayInterface
ServerSoftware
=
envServerSoftware
return
func
(
next
http
.
HandlerFunc
)
http
.
HandlerFunc
{
return
func
(
next
middleware
.
HandlerFunc
)
middleware
.
HandlerFunc
{
return
WebSockets
{
Next
:
next
,
Sockets
:
websocks
}
.
ServeHTTP
},
nil
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment