Skip to content
Open
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
4 changes: 3 additions & 1 deletion angular2-rest.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/// <reference path="node_modules/angular2/typings/browser.d.ts" />
import { Http, Request } from "angular2/http";
import { Observable } from "rxjs/Observable";
import 'rxjs/add/operator/map';
/**
* Angular 2 RESTClient class.
*
Expand Down Expand Up @@ -31,7 +33,7 @@ export declare class RESTClient {
* Set the base URL of REST resource
* @param {String} url - base URL
*/
export declare function BaseUrl(url: string): <TFunction extends Function>(Target: TFunction) => TFunction;
export declare function BaseUrl(url: string | Function): <TFunction extends Function>(Target: TFunction) => TFunction;
/**
* Set default headers for every method of the RESTClient
* @param {Object} headers - deafult headers in a key-value pair
Expand Down
42 changes: 23 additions & 19 deletions angular2-rest.js

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

2 changes: 1 addition & 1 deletion angular2-rest.js.map

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

18 changes: 13 additions & 5 deletions angular2-rest.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
///<reference path="node_modules/angular2/typings/browser.d.ts"/>
/*

angular2-rest
Expand Down Expand Up @@ -35,6 +36,7 @@ Response,
URLSearchParams
} from "angular2/http";
import {Observable} from "rxjs/Observable";
import 'rxjs/add/operator/map';

/**
* Angular 2 RESTClient class.
Expand Down Expand Up @@ -82,13 +84,19 @@ export class RESTClient {
* Set the base URL of REST resource
* @param {String} url - base URL
*/
export function BaseUrl(url: string) {
return function <TFunction extends Function>(Target: TFunction): TFunction {
Target.prototype.getBaseUrl = function() {
export function BaseUrl(url: string|Function) {
let urlFunction:string|Function = function() {
return url;
};
return Target;
};

if (typeof url === "function") {
urlFunction = url;
}

return function <TFunction extends Function>(Target: TFunction): TFunction {
Target.prototype.getBaseUrl = urlFunction;
return Target;
}
}

/**
Expand Down
Loading