This is the complete method signature for
1 2 3 4 5 6 7 8 9 10 11 12 13 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<ResourceProvider> resourceProviders = null, IEnumerable<IProtocolProvider> protocolProviders = null, IEnumerable<IContentTypeProvider> contentTypeProviders = null );
By changing the values of these parameters, you can configure RESTar to best serve your current application.
port parameter controls which HTTP port to register the RESTar handlers on. One Starcounter HTTP handler is registered on this port for each of the following HTTP verbs:
GET, POST, PATCH, PUT, DELETE, OPTIONS.
uri parameter is what is used for the root uri of the REST API. If the application is deployed locally, and the
port parameter is set to
8282, the RESTar API will be listening for requests on
To require authentication and authorization for all requests using API keys, set this parameter to
true. If set to
true, it’s required to include a configuration file path in the
To require the administrator of the application to whitelist all CORS origins that are allowed to make requests to this application, set the
allowAllOrigins parameter to
false. If set to
false, it’s required to include a configuration file path in the
requireApikey is set to
allowAllOrigins is set to
false, RESTar needs a configuration file to read API keys and/or whitelisted CORS origins from. How to administrate API keys and CORS origins is covered in the Administering a RESTar API section, but the path to the file needs to be provided by the developer.
prettyPrint parameter controls whether JSON output from RESTar is “pretty printed”, that is – indented – to increase human readability.
When the REST API aborts operations due to some error, for example a format error in the incoming request, information about the error is stored in the
RESTar.Admin.Error resource. The
daysToSaveErrors parameter controls after how many days the error should be deleted from the log.
By default, RESTar will use windows line endings,
\r\n, in serialized JSON output. To change this to linux line endings,
\n, set the value of
RESTar has support for add-ons in the form of resource providers. They provide a way to standardize RESTar operations for some data storage technology – for example SQLite. To include a resource provider in the RESTar instance, add it to a collection and assign to this parameter.
RESTar can also take add-ons in the form of protocol providers, objects that contain the logic for parsing requests and generating responses according to some external protocol, for example OData. To include a protocol provider in the RESTar instance, add it to a collection and assign to this parameter.
A third type of RESTar addon is content type providers. They add support for additional content types that can be used to read and write data from a RESTar application. Three content type providers (JSON, Excel, and XML) are already included with RESTar, but any additional providers must be added here.