pb33f / wiretap

The world's coolest API Validation and compliance tool. Validate APIs against OpenAPI specifications and much more
https://pb33f.io/wiretap/
Other
125 stars 18 forks source link

Added support for Websockets #107

Closed jacobm-splunk closed 8 months ago

jacobm-splunk commented 8 months ago

This MR aims to add support for proxying websockets to wiretap.

It skips validation on this endpoint as OpenAPI does not really support websocket specification.

I am not the most familiar with gorilla/websocket so I may have missed something.

daveshanley commented 8 months ago

Amazing work, will review ASAP!

jacobm-splunk commented 8 months ago

A couple of nits, other than that - it looks great.

Didn't we discuss the need to add in the endpoints in which to forward, or are you simple just doing a straight passthrough for any endpoint?

I have a user add the configuration for their endpoints and then register a handler on each one of those:

// Handle Websockets
for websocket := range wiretapConfig.WebsocketConfigs {
    mux.HandleFunc(websocket, handleWebsocket)
}

If that's not doing what I expect it to do, then I can totally change it, but since the websocket is opened through a http request to a specific endpoint, then I think this should work?