WordpressClient constructor
WordpressClient({
- required Uri baseUrl,
- BootstrapConfiguration bootstrapper(
- BootstrapBuilder builder
Default Constructor.
baseUrl
is the base url of the wordpress site.
path is the path of the url appended to your REST API.
bootstrapper
is a builder method for initializing the client.
After this, you will have to initialize the client with initialize method call.
In order to handle initialization in the constructor itself, call WordpressClient.initialize factory constructor.
You can change path per request basis as well. You will have to assign it in build()
method of request class which inherits from IRequest.
Implementation
WordpressClient({
required Uri baseUrl,
BootstrapConfiguration Function(BootstrapBuilder builder)? bootstrapper,
}) {
if (!baseUrl.isAbsolute) {
throw ArgumentError(
'The provided url is relative. Base URLs should always be an absolute URL.',
'baseUrl',
);
}
var configuration = const BootstrapConfiguration();
if (bootstrapper != null) {
configuration = bootstrapper(BootstrapBuilder());
}
_requester = InternalRequester.configure(
baseUrl,
configuration,
);
if (configuration.middlewares != null &&
configuration.middlewares!.isNotEmpty) {
_middlewares.addAll(configuration.middlewares!);
}
}