frostfs-s3-gw/legacy/neofs-router.go
Evgeniy Kulikov 1c6da41bee NFSSVC-25 Isolate health-checkers
- Add mime-type for health-check response
- Remove legacy health-checkers
2020-07-21 17:43:45 +03:00

67 lines
1.6 KiB
Go

package legacy
import (
"github.com/gorilla/mux"
"go.uber.org/zap"
)
func AttachS3API(r *mux.Router, obj ObjectLayer, l *zap.Logger) {
{ // should be removed in feature
// Initialize all help
initHelp()
// TODO: If this name is actually stays unchanges, move it to constants.
globalGatewayName = "NeoFS S3 Gate"
// Set when gateway is enabled
globalIsGateway = true
// 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))
}
// TODO: We need to move this code with globalConfigSys.Init()
// for now keep it here such that "s3" gateway layer initializes
// itself properly when KMS is set.
// Initialize server config.
srvCfg := newServerConfig()
// Override any values from ENVs.
lookupConfigs(srvCfg)
// hold the mutex lock before a new config is assigned.
globalServerConfigMu.Lock()
globalServerConfig = srvCfg
globalServerConfigMu.Unlock()
}
// Add API router.
registerAPIRouter(r, true, true)
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()
}