Fix in-path sink signature matching
The eventbus payload contained the trailing /__sink=..., so path matching failed.
This commit is contained in:
+14
-5
@@ -164,7 +164,7 @@ func (svc *sink) ProcessRequest(w http.ResponseWriter, r *http.Request) {
|
||||
body = http.MaxBytesReader(w, r.Body, 32<<10) // 32k limit
|
||||
}
|
||||
|
||||
if err := svc.process(srup.ContentType, w, r, body); err != nil {
|
||||
if err := svc.process(srup, w, r, body); err != nil {
|
||||
return SinkErrProcessingError(sap).Wrap(err)
|
||||
}
|
||||
|
||||
@@ -281,11 +281,12 @@ func (svc sink) handleRequest(r *http.Request) (*SinkRequestUrlParams, *errors.E
|
||||
// b) Max-body-size check might be limited via sink params
|
||||
// and io.Reader that is passed is limited w/ io.LimitReader
|
||||
//
|
||||
func (svc *sink) process(contentType string, w http.ResponseWriter, r *http.Request, body io.Reader) error {
|
||||
func (svc *sink) process(srup *SinkRequestUrlParams, w http.ResponseWriter, r *http.Request, body io.Reader) error {
|
||||
var (
|
||||
err error
|
||||
ctx = r.Context()
|
||||
sap = &sinkActionProps{
|
||||
err error
|
||||
ctx = r.Context()
|
||||
contentType = srup.ContentType
|
||||
sap = &sinkActionProps{
|
||||
contentType: contentType,
|
||||
}
|
||||
)
|
||||
@@ -330,6 +331,14 @@ func (svc *sink) process(contentType string, w http.ResponseWriter, r *http.Requ
|
||||
sanitizedURL.Path = sanitizedURL.Path[i+len(SinkBaseURL):]
|
||||
}
|
||||
|
||||
// Step 3: remove sink suffix if in path
|
||||
if srup.SignatureInPath {
|
||||
i := strings.Index(sanitizedURL.Path, SinkSignUrlParamName)
|
||||
if i > 0 {
|
||||
sanitizedURL.Path = sanitizedURL.Path[0 : i-1]
|
||||
}
|
||||
}
|
||||
|
||||
r.URL = sanitizedURL
|
||||
r.RequestURI = sanitizedURL.String()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user