mirror of
https://github.com/pgsty/minio.git
synced 2026-08-11 00:33:28 +03:00
api: Add new ListenBucketNotificationHandler. (#2336)
This API is precursor before implementing `minio lambda` and `mc` continous replication.
This new api is an extention to BucketNofication APIs.
// Request
```
GET /bucket?notificationARN=arn:minio:lambda:us-east-1:10:minio HTTP/1.1
...
...
```
// Response
```
{"Records": ...}
...
...
...
{"Records": ...}
```
This commit is contained in:
committed by
Anand Babu (AB) Periasamy
parent
90c20a8c11
commit
064c51162d
+14
-15
@@ -368,20 +368,10 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h
|
||||
Key: object,
|
||||
ETag: md5Sum,
|
||||
})
|
||||
setCommonHeaders(w)
|
||||
writeSuccessResponse(w, encodedSuccessResponse)
|
||||
|
||||
// Load notification config if any.
|
||||
nConfig, err := loadNotificationConfig(api.ObjectAPI, bucket)
|
||||
// Notifications not set, return.
|
||||
if err == errNoSuchNotifications {
|
||||
return
|
||||
}
|
||||
// For all other errors, return.
|
||||
if err != nil {
|
||||
errorIf(err, "Unable to load notification config for bucket: \"%s\"", bucket)
|
||||
return
|
||||
}
|
||||
setCommonHeaders(w)
|
||||
|
||||
writeSuccessResponse(w, encodedSuccessResponse)
|
||||
|
||||
// Fetch object info for notifications.
|
||||
objInfo, err := api.ObjectAPI.GetObjectInfo(bucket, object)
|
||||
@@ -390,8 +380,17 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h
|
||||
return
|
||||
}
|
||||
|
||||
// Notify object created event.
|
||||
notifyObjectCreatedEvent(nConfig, ObjectCreatedPost, bucket, objInfo)
|
||||
if eventN.IsBucketNotificationSet(bucket) {
|
||||
// Notify object created event.
|
||||
eventNotify(eventData{
|
||||
Type: ObjectCreatedPost,
|
||||
Bucket: bucket,
|
||||
ObjInfo: objInfo,
|
||||
ReqParams: map[string]string{
|
||||
"sourceIPAddress": r.RemoteAddr,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// HeadBucketHandler - HEAD Bucket
|
||||
|
||||
Reference in New Issue
Block a user