/// <summary> /// Attach the eMIP+ WebAPI to the given HTTP server. /// </summary> /// <param name="HTTPServer">A HTTP server.</param> /// <param name="URLPathPrefix">An optional prefix for the HTTP URIs.</param> /// <param name="HTTPRealm">The HTTP realm, if HTTP Basic Authentication is used.</param> /// <param name="HTTPLogins">An enumeration of logins for an optional HTTP Basic Authentication.</param> /// /// <param name="XMLNamespaces">An optional delegate to process the XML namespaces.</param> /// <param name="XMLPostProcessing">An optional delegate to process the XML after its final creation.</param> public WebAPI(HTTPServer <RoamingNetworks, RoamingNetwork> HTTPServer, HTTPPath?URLPathPrefix = null, String HTTPRealm = DefaultHTTPRealm, IEnumerable <KeyValuePair <String, String> > HTTPLogins = null, XMLNamespacesDelegate XMLNamespaces = null, XMLPostProcessingDelegate XMLPostProcessing = null, CustomOperatorIdMapperDelegate CustomOperatorIdMapper = null, CustomEVSEIdMapperDelegate CustomEVSEIdMapper = null) { this.HTTPServer = HTTPServer ?? throw new ArgumentNullException(nameof(HTTPServer), "The given HTTP server must not be null!"); this.URLPathPrefix = URLPathPrefix ?? DefaultURLPathPrefix; this.HTTPRealm = HTTPRealm.IsNotNullOrEmpty() ? HTTPRealm : DefaultHTTPRealm; this.HTTPLogins = HTTPLogins ?? new KeyValuePair <String, String> [0]; this.DNSClient = HTTPServer.DNSClient; this.XMLNamespaces = XMLNamespaces; this.XMLPostProcessing = XMLPostProcessing; this.CustomOperatorIdMapper = CustomOperatorIdMapper; this.CustomEVSEIdMapper = CustomEVSEIdMapper; this._CPOAdapters = new List <WWCPCPOAdapter>(); // Link HTTP events... HTTPServer.RequestLog += (HTTPProcessor, ServerTimestamp, Request) => RequestLog.WhenAll(HTTPProcessor, ServerTimestamp, Request); HTTPServer.ResponseLog += (HTTPProcessor, ServerTimestamp, Request, Response) => ResponseLog.WhenAll(HTTPProcessor, ServerTimestamp, Request, Response); HTTPServer.ErrorLog += (HTTPProcessor, ServerTimestamp, Request, Response, Error, LastException) => ErrorLog.WhenAll(HTTPProcessor, ServerTimestamp, Request, Response, Error, LastException); var LogfilePrefix = "HTTPSSEs" + Path.DirectorySeparatorChar; this.DebugLog = HTTPServer.AddJSONEventSource(EventIdentification: DebugLogId, URLTemplate: this.URLPathPrefix + "/DebugLog", MaxNumberOfCachedEvents: 10000, RetryIntervall: TimeSpan.FromSeconds(5), EnableLogging: true, LogfilePrefix: LogfilePrefix); RegisterURITemplates(); }
public static Operator_Id ToEMIP(this ChargingStationOperator_Id OperatorId, CustomOperatorIdMapperDelegate CustomOperatorIdMapper = null) => Operator_Id.Parse(CustomOperatorIdMapper != null ? CustomOperatorIdMapper(OperatorId.ToString()) : OperatorId.ToString());