Skip to content

Instantly share code, notes, and snippets.

@matzew
Created September 5, 2012 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matzew/3636354 to your computer and use it in GitHub Desktop.
Save matzew/3636354 to your computer and use it in GitHub Desktop.
BaseURL and service endpoint

We need to separate the 'base URL' and the service endpoint, when creating new pipes / a new pipeline...

Proposed API

/**
 * A factory method to instantiate the AGPipeline, which
 * contains a RESTful pipe.
 *
 * @param name the name of the first AGPipe object
 * @param baseURL the URL of the server
 * @param endpoint the serivce endpoint, if differs from the pipe name.
 *
 * @return the AGPipeline object
 */
+(id) pipelineWithPipe:(NSString*) name baseURL:(NSURL*)baseURL endpoint:(NSString*)endpoint;

(Note: currently the NSURL type is named 'url', that will be changed to 'baseURL')

Usage

NSURL* serverURL = [NSURL URLWithString:@"http://todo-aerogear.rhcloud.com/todo-server/"];
AGPipeline* pipeline = [AGPipeline pipelineWithPipe:@"bad name" baseURL:serverURL endpoint:@"projects"]

// get the pipe object for the 'projects' endpoint:
id<AGPipe> myPipe = [pipeline get@"bad name"];

NSString* url = [myPipe url];

The 'url' is than equivalent to "http://todo-aerogear.rhcloud.com/todo-server/projects/"....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment