MCPcopy
hub / github.com/scality/cloudserver / bucketGetCors

Function bucketGetCors

lib/api/bucketGetCors.js:19–48  ·  view source on GitHub ↗

* Bucket Get CORS - Get bucket cors configuration * @param {AuthInfo} authInfo - Instance of AuthInfo class with requester's info * @param {object} request - http request object * @param {object} log - Werelogs logger * @param {function} callback - callback to server * @return {undefined}

(authInfo, request, log, callback)

Source from the content-addressed store, hash-verified

17 * @return {undefined}
18 */
19function bucketGetCors(authInfo, request, log, callback) {
20 const bucketName = request.bucketName;
21 const metadataValParams = {
22 authInfo,
23 bucketName,
24 requestType: REQUEST_TYPE,
25 request,
26 };
27
28 return standardMetadataValidateBucket(metadataValParams, request.actionImplicitDenies, log, (err, bucket) => {
29 const corsHeaders = collectCorsHeaders(request.headers.origin, request.method, bucket);
30 if (err) {
31 monitoring.promMetrics('GET', bucketName, err.code, METRICS_ACTION);
32 return callback(err, null, corsHeaders);
33 }
34
35 const cors = bucket.getCors();
36 if (!cors) {
37 log.debug('cors configuration does not exist', { method: REQUEST_TYPE });
38 monitoring.promMetrics('GET', bucketName, 404, METRICS_ACTION);
39 return callback(errors.NoSuchCORSConfiguration, null, corsHeaders);
40 }
41 log.trace('converting cors configuration to xml');
42 const xml = convertToXml(cors);
43
44 pushMetric(METRICS_ACTION, log, { authInfo, bucket: bucketName });
45 monitoring.promMetrics('GET', bucketName, '200', METRICS_ACTION);
46 return callback(null, xml, corsHeaders);
47 });
48}
49
50module.exports = bucketGetCors;

Callers 4

transientBucket.jsFile · 0.85
_comparePutGetXmlFunction · 0.85

Calls 7

collectCorsHeadersFunction · 0.85
pushMetricFunction · 0.85
getCorsMethod · 0.80
debugMethod · 0.80
traceMethod · 0.80
convertToXmlFunction · 0.70

Tested by

no test coverage detected