github.com/voedger/voedger@v0.0.0-20240520144910-273e84102129/pkg/ihttpctl/provide.go (about) 1 /* 2 * Copyright (c) 2022-present unTill Pro, Ltd. 3 * @author Maxim Geraskin 4 */ 5 6 package ihttpctl 7 8 import ( 9 "fmt" 10 11 "github.com/voedger/voedger/pkg/ihttp" 12 ) 13 14 func NewHTTPProcessorController(processor ihttp.IHTTPProcessor, staticResources []StaticResourcesType, redirections RedirectRoutes, defaultRedirection DefaultRedirectRoute, acmeDomains ihttp.AcmeDomains, appRequestHandlers AppRequestHandlers) IHTTPProcessorController { 15 srs := StaticResourcesType{} 16 for _, sr := range staticResources { 17 for url, fs := range sr { 18 if _, exists := srs[url]; exists { 19 panic(fmt.Sprintf("static resource with duplicate url %s", url)) 20 } 21 srs[url] = fs 22 } 23 } 24 if len(defaultRedirection) > 1 { 25 panic("default redirection should be single record") 26 } 27 httpController := &httpProcessorController{ 28 processor: processor, 29 staticResources: srs, 30 redirections: redirections, 31 defaultRedirection: defaultRedirection, 32 apps: appRequestHandlers, 33 } 34 for _, acmeDomain := range acmeDomains { 35 httpController.processor.AddAcmeDomain(acmeDomain) 36 } 37 return httpController 38 }