Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion dist/ngRestAdapter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,27 @@ declare module NgRestAdapter {
interface ISkipInterceptorFunction {
(rejection: ng.IHttpPromiseCallbackArg<any>): boolean;
}
interface INgRestAdapterRequestConfig extends ng.IRequestConfig {
ngRestAdapterServiceConfig: INgRestAdapterServiceConfig;
isBaseUrl: boolean;
}
}
declare module NgRestAdapter {
class NgRestAdapterService implements INgRestAdapterService {
private config;
private $http;
private uuid4;
private originalConfig;
private apiErrorHandler;
private skipInterceptorRoutes;
/**
* Construct the service with dependencies injected
* @param config
* @param $http
* @param uuid4
* @param originalConfig
*/
constructor(config: INgRestAdapterServiceConfig, $http: ng.IHttpService, uuid4: any);
constructor(config: INgRestAdapterServiceConfig, $http: ng.IHttpService, uuid4: any, originalConfig?: INgRestAdapterServiceConfig);
private sendRequest(method, url, requestHeaders?, data?, configOverrides?);
options(url: string, headers?: IHeaderConfig, configOverrides?: ng.IRequestShortcutConfig): ng.IHttpPromise<any>;
get(url: string, headers?: IHeaderConfig, configOverrides?: ng.IRequestShortcutConfig): ng.IHttpPromise<any>;
Expand Down
16 changes: 9 additions & 7 deletions dist/ngRestAdapter.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/ngRestAdapter.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"main-bower-files": "^2.8.2",
"merge2": "^0.3.6",
"minimatch": "^2.0.8",
"mocha": "^2.2.5",
"mocha": "^2.3.2",
"requirejs": "^2.1.18",
"run-sequence": "^1.1.1",
"sinon": "^1.15.4",
Expand Down
6 changes: 6 additions & 0 deletions src/ngRestAdapterInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,10 @@ module NgRestAdapter {
(rejection:ng.IHttpPromiseCallbackArg<any>):boolean;
}


export interface INgRestAdapterRequestConfig extends ng.IRequestConfig{
ngRestAdapterServiceConfig:INgRestAdapterServiceConfig;
isBaseUrl:boolean;
}

}
15 changes: 9 additions & 6 deletions src/ngRestAdapterService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ module NgRestAdapter {
* @param config
* @param $http
* @param uuid4
* @param originalConfig
*/
constructor(
private config:INgRestAdapterServiceConfig,
private $http: ng.IHttpService,
private uuid4
private uuid4,
private originalConfig?:INgRestAdapterServiceConfig
) {

}
Expand All @@ -34,12 +36,13 @@ module NgRestAdapter {
};

//set the default config
var requestConfig:ng.IRequestConfig = {
var requestConfig:INgRestAdapterRequestConfig = {
method: method,
url: this.config.baseUrl + url,
headers: _.defaults(requestHeaders, defaultHeaders),
responseType: 'json', //it could always be json as even a head request might throw an exception as json
ngRestAdapterServiceConfig: this.config
ngRestAdapterServiceConfig: this.config,
isBaseUrl: !this.originalConfig || this.config.baseUrl === this.originalConfig.baseUrl,
};

//if data is present, attach it to config
Expand All @@ -49,7 +52,7 @@ module NgRestAdapter {

//handle overrides
if (!_.isEmpty(configOverrides)){
requestConfig = <ng.IRequestConfig>_.defaults(configOverrides, requestConfig);
requestConfig = <INgRestAdapterRequestConfig>_.defaults(configOverrides, requestConfig);
}

var resultPromise = this.$http(requestConfig);
Expand Down Expand Up @@ -89,14 +92,14 @@ module NgRestAdapter {

let config = <INgRestAdapterServiceConfig>_.defaults({baseUrl:url}, this.config);

return new NgRestAdapterService(config, this.$http, this.uuid4);
return new NgRestAdapterService(config, this.$http, this.uuid4, this.config);
}

public skipInterceptor(shouldSkip:ISkipInterceptorFunction = () => true):NgRestAdapterService {

let config = <INgRestAdapterServiceConfig>_.defaults({skipInterceptor:shouldSkip}, this.config);

return new NgRestAdapterService(config, this.$http, this.uuid4);
return new NgRestAdapterService(config, this.$http, this.uuid4, this.config);

}

Expand Down
Loading