frostfs-s3-gw/legacy/neofs-router.go

48 lines
1 KiB
Go
Raw Normal View History

2020-07-12 23:00:47 +00:00
package legacy
import (
"github.com/gorilla/mux"
2020-07-13 10:22:37 +00:00
"go.uber.org/zap"
2020-07-12 23:00:47 +00:00
)
2020-07-13 10:22:37 +00:00
func AttachS3API(r *mux.Router, obj ObjectLayer, l *zap.Logger) {
2020-07-12 23:00:47 +00:00
// Add healthcheck router
registerHealthCheckRouter(r)
2020-07-12 23:00:47 +00:00
// Add server metrics router
registerMetricsRouter(r)
2020-07-12 23:00:47 +00:00
// Add API router.
registerAPIRouter(r, true, true)
2020-07-12 23:00:47 +00:00
layer := NewGatewayLayerWithLocker(obj)
// Once endpoints are finalized, initialize the new object api in safe mode.
globalObjLayerMutex.Lock()
globalSafeMode = true
globalObjectAPI = layer
globalObjLayerMutex.Unlock()
// Calls all New() for all sub-systems.
newAllSubsystems()
// Verify if object layer supports
// - encryption
// - compression
verifyObjectLayerFeatures("gateway NeoFS", layer)
// Disable safe mode operation, after all initialization is over.
globalObjLayerMutex.Lock()
globalSafeMode = false
globalObjLayerMutex.Unlock()
2020-07-13 10:22:37 +00:00
// Handle gateway specific env
gatewayHandleEnvVars()
// Set system resources to maximum.
if err := setMaxResources(); err != nil {
l.Warn("could not set max resources",
zap.Error(err))
}
2020-07-12 23:00:47 +00:00
}