igm / sockjs-go

WebSocket emulation - Go server library
BSD 3-Clause "New" or "Revised" License
514 stars 100 forks source link

RFC: Add the possibility set allowed methods on NewHandler func #107

Closed horstmannmat closed 10 months ago

horstmannmat commented 10 months ago

ATM, there is no way of restricting Methods for socksJS (e.g. If I don't want my application to use XHR)

My idea is to add a bitmask (using the ReceiverType)on the NewHandler function, the default would be all, if not default, then it would be only the types within the bitmask

igm commented 10 months ago

there's Options struct that is passed to NewHandler(...) func. Would it make sense to add more fields there? e.g. DisableXhr or DisableEventStream. It'll be backwards compatible this way

horstmannmat commented 10 months ago

Yeah, I was considering the same thing, but would not be too polluted having one boolean for each method? A array of allowed type maybe? And Len(array) == all types?

igm commented 10 months ago

I'd probably prefer one boolean for each method, there'll be 5 more Disable* flags:

    DisableXHR
    DisableXHRStreaming
    DisableEventSource
    DisableHtmlFile
    DisableJSONP

default is flase which means it is backwards compatible and simple at the same time.