/** * Specify the XSRF token header name. * * @param xsrfTokenHeaderName The XSRF token header name. * * @return this {@link com.gwtplatform.dispatch.rest.client.gin.BaseRestDispatchModuleBuilder builder} object. */ public B xsrfTokenHeaderName(String xsrfTokenHeaderName) { this.xsrfTokenHeaderName = xsrfTokenHeaderName; return self(); }
@Override protected void configureDispatch() { // Common install(new CommonGinModule()); install(new SerializationModule()); install(builder.getCoreModule()); bind(RestFilterRegistry.class).to(builder.getFilterRegistry()).in(Singleton.class); // Constants / Configurations // It's not possible to bind non-native type constants, so we must encode them at compile-time and decode them // at runtime (ie: Global Parameters) String globalHeaderParams = bindingsSerializer.serialize(builder.getGlobalHeaderParams()); String globalQueryParams = bindingsSerializer.serialize(builder.getGlobalQueryParams()); bindConstant().annotatedWith(XsrfHeaderName.class).to(builder.getXsrfTokenHeaderName()); bindConstant().annotatedWith(RequestTimeout.class).to(builder.getRequestTimeoutMs()); bindConstant().annotatedWith(DefaultDateFormat.class).to(builder.getDefaultDateFormat()); bindConstant().annotatedWith(GlobalHeaderParams.class).to(globalHeaderParams); bindConstant().annotatedWith(GlobalQueryParams.class).to(globalQueryParams); }
/** * Specify an alternate REST filter registry. * * @param filterRegistry A {@link com.gwtplatform.dispatch.rest.client.filter.RestFilterRegistry} class. * * @return this {@link com.gwtplatform.dispatch.rest.client.gin.BaseRestDispatchModuleBuilder builder} object. */ public B filterRegistry(Class<? extends RestFilterRegistry> filterRegistry) { this.filterRegistry = filterRegistry; return self(); }
/** * Specify the number of milliseconds to wait for a request to complete. If the timeout is reached, {@link * com.google.gwt.user.client.rpc.AsyncCallback#onFailure(Throwable) AsyncCallback#onFailure(Throwable)} will be * called. Default is <code>0</code>: no timeout. * * @param timeoutMs The maximum time to wait, in milliseconds, or {@code 0} for no timeout. * * @return this {@link com.gwtplatform.dispatch.rest.client.gin.BaseRestDispatchModuleBuilder builder} object. */ public B requestTimeout(int timeoutMs) { this.requestTimeoutMs = timeoutMs; return self(); }
/** * Specify the pattern to use to format dates before they are sent to the end-point. The pattern must follow the * rules defined by {@link com.google.gwt.i18n.shared.DateTimeFormat DateTimeFormat}. * <p/> * Default is {@link com.gwtplatform.dispatch.rest.shared.DateFormat#DEFAULT}. * * @param defaultDateFormat The pattern used to format dates. * * @return this {@link com.gwtplatform.dispatch.rest.client.gin.BaseRestDispatchModuleBuilder builder} object. */ public B defaultDateFormat(String defaultDateFormat) { this.defaultDateFormat = defaultDateFormat; return self(); }
/** * Initiate the creation of a global query parameter that will be attached to all requests. * * @param key The key used for this parameter * * @return the parameter builder instance */ public RestParameterBuilder<B> addGlobalQueryParam(String key) { return new RestParameterBuilder<>(self(), Type.QUERY, globalQueryParams, key); }
/** * Initiate the creation of a global header parameter that will be attached to all requests. * * @param key The key used for this parameter * * @return the parameter builder instance */ public RestParameterBuilder<B> addGlobalHeaderParam(String key) { return new RestParameterBuilder<>(self(), Type.HEADER, globalHeaderParams, key); }