NOISSUE - Add WebSocket support to HTTP Proxy#87
Conversation
7999968 to
ad1a8a7
Compare
ddd66c0 to
59aa0c1
Compare
486bd1a to
1fd2cfd
Compare
|
@arvindh123 Please resolve the comment and conflicts. |
2d5f3da to
369ec37
Compare
|
@arvindh123 Please resolve conflicts. |
2335a5a to
7697147
Compare
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: Arvindh <arvindh91@gmail.com>
f22b8fc to
d3a1484
Compare
Signed-off-by: Arvindh <arvindh91@gmail.com>
d3a1484 to
c5324d4
Compare
pkg/common/origincheck.go
Outdated
| const errNotAllowed = "origin - %s is not allowed" | ||
|
|
||
| type OriginChecker interface { | ||
| CheckOrigin(r *http.Request) error |
There was a problem hiding this comment.
The idea of OriginChecker and BypassMatcher was to have the same interface signature so we can use a single interface:
type Checker interface {
Check(*http.Request) error
}|
|
||
| import "strings" | ||
|
|
||
| func AddSuffixSlash(path string) string { |
There was a problem hiding this comment.
Let's avoid having generic helpers/common/util packags. Checkers are related to HTTP layer, while suffix is transport-layer path handler.
pkg/http/http.go
Outdated
| func (p *Proxy) handleWebSocket(w http.ResponseWriter, r *http.Request, s *session.Session) { | ||
| topic := r.URL.Path | ||
| ctx := session.NewContext(context.Background(), s) | ||
| if err := p.session.AuthConnect(ctx); err != nil { |
There was a problem hiding this comment.
Create a new ws.go file with all the WS-related handling.
pkg/http/http.go
Outdated
| } | ||
| return fmt.Errorf("%s error: %w", prefix, err) | ||
| } | ||
|
|
There was a problem hiding this comment.
This can be confusing as to what is UP and what is DOWN. Maybe simpler "between client and mGate" and "between mGate and server"is better.
Signed-off-by: Arvindh <arvindh91@gmail.com>
211b0f1 to
fe28d8d
Compare
Signed-off-by: Arvindh <arvindh91@gmail.com>
cd88db4 to
5b1db62
Compare
pkg/http/checkers.go
Outdated
| type Checkers interface { | ||
| ShouldBypass(r *http.Request) error | ||
| CheckOrigin(r *http.Request) error | ||
| } |
There was a problem hiding this comment.
@arvindh123 Please use a single interface Checker with Check method. There is no need for this complication. Use two implementations - one for origin and the other for bypass- according to needs.
pkg/http/http.go
Outdated
| switch { | ||
| case ok: | ||
| return username, password | ||
| case len(r.URL.Query()[authzQueryKey]) != 0: |
There was a problem hiding this comment.
Use r.URL.Query().Get(authzQueryKey) instead.
Signed-off-by: Arvindh <arvindh91@gmail.com>
dborovcanin
left a comment
There was a problem hiding this comment.
No need for two files with the checker suffix - a single file checker.go with both checkers implementations is fine, since implementations are relatively simple.
pkg/http/bypasschecker.go
Outdated
| "regexp" | ||
| ) | ||
|
|
||
| const errNotByPassed = "route - %s is not in bypass list" |
There was a problem hiding this comment.
Rename to errNotBypassFmt for better self-documenting.
pkg/http/bypasschecker.go
Outdated
| @@ -0,0 +1,51 @@ | |||
| // Copyright (c) Abstract Machines | |||
There was a problem hiding this comment.
Use bypass instead of byPass since it's cleaner to use bypass than by pass.
pkg/http/http.go
Outdated
| return username, password | ||
| case len(r.URL.Query()[authzQueryKey]) != 0: | ||
| password = r.URL.Query()[authzQueryKey][0] | ||
| case len(r.URL.Query().Get(authzQueryKey)) != 0: |
There was a problem hiding this comment.
No need for len, compare to empty string.
| @@ -0,0 +1,13 @@ | |||
| // Copyright (c) Abstract Machines | |||
There was a problem hiding this comment.
Rename the file to path.go.
|
@arvindh123 Please address remarks here. |
Signed-off-by: Arvindh <arvindh91@gmail.com>
c592a92 to
e40a4bc
Compare

Pull request title should be
MF-XXX - descriptionorNOISSUE - descriptionwhere XXX is ID of issue that this PR relate to.Please review the CONTRIBUTING.md file for detailed contributing guidelines.
What does this do?
Which issue(s) does this PR fix/relate to?
Put here
Resolves #XXXto auto-close the issue that your PR fixes (if such)List any changes that modify/break current functionality
Have you included tests for your changes?
Did you document any new/modified functionality?
Notes