Inherits from NSObject
Conforms to RKRouter
Declared in RKObjectRouter.h
RKObjectRouter.m

Overview

An implementation of the RKRouter protocol that is suitable for use in either static or dynamic route generation. Static routes are added by simply encoding the resourcePath that the mappable object should be sent to when a GET, POST, PUT or DELETE action is invoked. Dynamic routes are available by encoding key paths into the resourcePath using a single colon delimiter, such as /users/:userID

Tasks

Other Methods

  • – routeClass:toResourcePathPattern:

    Register a mapping from an object class to a resource path. This resourcePath can be static (i.e. /this/is/the/path) or dynamic (i.e. /users/:userID/:username). Dynamic routes are evaluated against the object being routed using Key-Value coding and coerced into a string. NOTE – The pattern matcher fully supports KVM, so /:key1.otherKey normally resolves as it would in any other KVM situation, … otherKey is a sub-key on a the object represented by key1. This presents a problem in situations where you might want to build a pattern like /:filename.json, where the dot isn’t intended as a sub-key on the dynamic “filename”, but rather it is part of the “json” static string. In these instances, you need to escape the dot with two backslashes, like so: /:filename\.json

  • – routeClass:toResourcePathPattern:forMethod:

    Register a mapping from an object class to a resource path for a specific HTTP method.

  • – routeClass:toResourcePathPattern:forMethod:escapeRoutedPath:

    Register a mapping from an object class to a resource path for a specific HTTP method, optionally adding url escapes to the path. This urlEscape flag comes in handy when you want to provide your own fully escaped dynamic resource path via a method/attribute on the object model. For example, if your Person model has a string attribute titled “polymorphicResourcePath” that returns @“/this/is/the/path”, you should configure the route with url escapes ‘off’, otherwise the router will return @“%2Fthis%2Fis%2Fthe%2Fpath”.

Other Methods

Instance Methods

resourcePathForObject:method:

Returns the resource path to send requests for a given object and HTTP method

- (NSString *)resourcePathForObject:(NSObject *)object method:(RKRequestMethod)method

Declared In

RKRouter.h

routeClass:toResourcePathPattern:

Register a mapping from an object class to a resource path. This resourcePath can be static (i.e. /this/is/the/path) or dynamic (i.e. /users/:userID/:username). Dynamic routes are evaluated against the object being routed using Key-Value coding and coerced into a string. NOTE – The pattern matcher fully supports KVM, so /:key1.otherKey normally resolves as it would in any other KVM situation, … otherKey is a sub-key on a the object represented by key1. This presents a problem in situations where you might want to build a pattern like /:filename.json, where the dot isn’t intended as a sub-key on the dynamic “filename”, but rather it is part of the “json” static string. In these instances, you need to escape the dot with two backslashes, like so: /:filename\.json

- (void)routeClass:(Class)objectClass toResourcePathPattern:(NSString *)resourcePathPattern

See Also

Declared In

RKObjectRouter.h

routeClass:toResourcePathPattern:forMethod:

Register a mapping from an object class to a resource path for a specific HTTP method.

- (void)routeClass:(Class)objectClass toResourcePathPattern:(NSString *)resourcePathPattern forMethod:(RKRequestMethod)method

See Also

Declared In

RKObjectRouter.h

routeClass:toResourcePathPattern:forMethod:escapeRoutedPath:

Register a mapping from an object class to a resource path for a specific HTTP method, optionally adding url escapes to the path. This urlEscape flag comes in handy when you want to provide your own fully escaped dynamic resource path via a method/attribute on the object model. For example, if your Person model has a string attribute titled “polymorphicResourcePath” that returns @“/this/is/the/path”, you should configure the route with url escapes ‘off’, otherwise the router will return @“%2Fthis%2Fis%2Fthe%2Fpath”.

- (void)routeClass:(Class)objectClass toResourcePathPattern:(NSString *)resourcePathPattern forMethod:(RKRequestMethod)method escapeRoutedPath:(BOOL)addEscapes

See Also

Declared In

RKObjectRouter.h