/// <summary> /// Initiates the RESTar interface /// </summary> /// <param name="port">The port that RESTar should listen on</param> /// <param name="uri">The URI that RESTar should listen on. E.g. '/rest'</param> /// <param name="configFilePath">The path to the config file containing API keys and /// allowed origins</param> /// <param name="prettyPrint">Should JSON output be pretty print formatted as default? /// (can be changed in settings during runtime)</param> /// <param name="daysToSaveErrors">The number of days to save errors in the Error resource</param> /// <param name="requireApiKey">Should the REST API require an API key?</param> /// <param name="allowAllOrigins">Should any origin be allowed to make CORS requests?</param> /// <param name="lineEndings">The line endings to use when writing JSON</param> /// <param name="entityResourceProviders">External entity resource providers for the RESTar instance</param> /// <param name="protocolProviders">External protocol providers for the RESTar instance</param> /// <param name="contentTypeProviders">External content type providers for the RESTar instance</param> public static void Init ( ushort port = 8282, string uri = "/rest", bool requireApiKey = false, bool allowAllOrigins = true, string configFilePath = null, bool prettyPrint = true, ushort daysToSaveErrors = 30, LineEndings lineEndings = LineEndings.Windows, IEnumerable <IEntityResourceProvider> entityResourceProviders = null, IEnumerable <IProtocolProvider> protocolProviders = null, IEnumerable <IContentTypeProvider> contentTypeProviders = null ) { try { ProcessUri(ref uri); Settings.Init(port, uri, false, prettyPrint, daysToSaveErrors, lineEndings); Log.Init(); DynamitConfig.Init(true, true); ResourceFactory.MakeResources(entityResourceProviders?.ToArray()); ContentTypeController.SetupContentTypeProviders(contentTypeProviders?.ToList()); ProtocolController.SetupProtocolProviders(protocolProviders?.ToList()); RequireApiKey = requireApiKey; AllowAllOrigins = allowAllOrigins; ConfigFilePath = configFilePath; NetworkController.AddNetworkBindings(new ScNetworkProvider()); Initialized = true; UpdateConfiguration(); DatabaseIndex.Init(); DbOutputFormat.Init(); ResourceFactory.BindControllers(); ResourceFactory.FinalCheck(); ProtocolController.OnInit(); Webhook.Check(); WebhookLogSettings.Init(); RegisterStaticIndexes(); RunCustomMigrationLogic(); } catch { Initialized = false; RequireApiKey = default; AllowAllOrigins = default; ConfigFilePath = default; NetworkController.RemoveNetworkBindings(); Settings.Clear(); NewState(); throw; } }