X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=E2Manager%2Fproviders%2Fhttpmsghandlerprovider%2Frequest_handler_provider.go;fp=E2Manager%2Fproviders%2Fhttpmsghandlerprovider%2Frequest_handler_provider.go;h=0000000000000000000000000000000000000000;hb=33f84e1a0998af025880be3e8eb087fac34af731;hp=6fa28077138d711b7a481a408402b6d0e0da3cac;hpb=0e58b60a82f5912f815be9292fe0c072a80b79a7;p=ric-plt%2Fe2mgr.git diff --git a/E2Manager/providers/httpmsghandlerprovider/request_handler_provider.go b/E2Manager/providers/httpmsghandlerprovider/request_handler_provider.go deleted file mode 100644 index 6fa2807..0000000 --- a/E2Manager/providers/httpmsghandlerprovider/request_handler_provider.go +++ /dev/null @@ -1,54 +0,0 @@ -// -// Copyright 2019 AT&T Intellectual Property -// Copyright 2019 Nokia -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package httpmsghandlerprovider - -import ( - "e2mgr/handlers/httpmsghandlers" - "e2mgr/logger" - "e2mgr/rNibWriter" - "errors" - "fmt" -) - -var requestMap map[string]httpmsghandlers.Handler - -type RequestHandlerProvider struct{} - -func NewRequestHandlerProvider(rnibWriterProvider func() rNibWriter.RNibWriter) *RequestHandlerProvider { - requestMap = initRequestMap(rnibWriterProvider) - return &RequestHandlerProvider{} -} - -func initRequestMap(rnibWriterProvider func() rNibWriter.RNibWriter) map[string]httpmsghandlers.Handler { - return map[string]httpmsghandlers.Handler{ - "x2-setup": httpmsghandlers.NewSetupRequestHandler(rnibWriterProvider), - "endc-setup": httpmsghandlers.NewEndcSetupRequestHandler(rnibWriterProvider), - } -} - -func (provider RequestHandlerProvider) GetHandler(logger *logger.Logger, requestType string) (httpmsghandlers.Handler, error) { - handler, ok := requestMap[requestType] - - if !ok { - errorMessage := fmt.Sprintf("#request_handler_provider.GetHandler - Cannot find handler for request type: %s", requestType) - logger.Errorf(errorMessage) - return nil, errors.New(errorMessage) - } - - return handler, nil -}