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

Function bucketGetWebsite

lib/api/bucketGetWebsite.js:20–49  ·  view source on GitHub ↗

* Bucket Get Website - Get bucket website 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

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

Callers 3

_comparePutGetXmlFunction · 0.85
transientBucket.jsFile · 0.85

Calls 6

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

Tested by

no test coverage detected