-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TT-12893]: Adding first implementation of streams API #6496
Changes from all commits
f91b5bb
c100416
649246f
f836206
448600e
5085d46
f9a8ada
2a35bde
95102b9
155e860
ed4f297
9fa9e11
2e7fd38
5ac6fb8
fe874e7
ed19b44
47772fc
8495893
a0bf8a0
a310bc7
d096c8d
a254a72
5e94fee
74c65ef
bb554c5
e5c9184
1398fa7
81c48b1
f8d36a4
19519ae
3b0e40c
a3956df
444fa16
8c70245
ec949b5
22b77ea
0c2e70d
75689c4
c4f9fc9
dd96a6a
6766c86
1cc0698
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,10 +53,12 @@ tyk-gateway.pid | |
*.go-e | ||
|
||
tyk_linux_* | ||
.aider* | ||
/dist/ | ||
|
||
.terraform** | ||
.terraform.lock.hcl | ||
.task/ | ||
*.test | ||
|
||
main | ||
main |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
input: | ||
stdin: {} | ||
|
||
output: | ||
http_server: | ||
address: "0.0.0.0:4196" | ||
path: /get | ||
stream_path: /get/stream | ||
ws_path: /get/ws | ||
allowed_verbs: | ||
- GET |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,10 @@ var ( | |
LivenessCheck: LivenessCheckConfig{ | ||
CheckDuration: time.Second * 10, | ||
}, | ||
Streaming: StreamingConfig{ | ||
Enabled: false, | ||
AllowUnsafe: []string{}, | ||
}, | ||
} | ||
) | ||
|
||
|
@@ -663,6 +667,12 @@ func (pwl *PortsWhiteList) Decode(value string) error { | |
return nil | ||
} | ||
|
||
// Add this new struct definition | ||
type StreamingConfig struct { | ||
Enabled bool `json:"enabled"` | ||
AllowUnsafe []string `json:"allow_unsafe"` | ||
} | ||
|
||
// Config is the configuration object used by Tyk to set up various parameters. | ||
type Config struct { | ||
// Force your Gateway to work only on a specific domain name. Can be overridden by API custom domain. | ||
|
@@ -1131,6 +1141,22 @@ type Config struct { | |
|
||
// OAS holds the configuration for various OpenAPI-specific functionalities | ||
OAS OASConfig `json:"oas_config"` | ||
|
||
Streaming StreamingConfig `json:"streaming"` | ||
|
||
Labs labsConfig `json:"labs"` | ||
} | ||
|
||
type labsConfig map[string]interface{} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a public symbol as it's part of the Config data model |
||
|
||
func (lc *labsConfig) Decode(value string) error { | ||
var temp map[string]interface{} | ||
if err := json.Unmarshal([]byte(value), &temp); err != nil { | ||
log.Error("Error unmarshalling labsConfig: ", err) | ||
return err | ||
} | ||
*lc = temp | ||
return nil | ||
} | ||
|
||
// OASConfig holds the configuration for various OpenAPI-specific functionalities | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ func (m *MiddlewareContextVars) Name() string { | |
} | ||
|
||
func (m *MiddlewareContextVars) EnabledForSpec() bool { | ||
return m.Spec.EnableContextVars | ||
return true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea for streaming is to have context vars always enabled. There won't be an option to disable it in UI |
||
} | ||
|
||
// ProcessRequest will run any checks on the request on the way through the system, return an error to have the chain fail | ||
|
@@ -46,6 +46,13 @@ func (m *MiddlewareContextVars) ProcessRequest(w http.ResponseWriter, r *http.Re | |
contextDataObject[name] = c.Value | ||
} | ||
|
||
for key, vals := range r.Form { | ||
name := "request_data_" + strings.Replace(key, "-", "_", -1) | ||
if len(vals) > 0 { | ||
contextDataObject[name] = vals[0] | ||
} | ||
} | ||
|
||
ctxSetData(r, contextDataObject) | ||
|
||
return nil, http.StatusOK | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment should be changed