Is there any way that I cam make route path case insensitive ?
sateeshkumardamera opened this issue · comments
Sateesh Kumar commented
It seems the routes are case sensitive. how can I make them case insensitive?
Cătălin Stan commented
You can use regex path definitions as described at http://cocoadocs.org/docsets/Criollo/0.4.17/Classes/CRRouter.html, although the path definitions could start looking quite messy.
Cătălin Stan commented
I think that a more elegant way is to subclass CRHTTPServer
and override (NSArray<CRRouteMatchingResult *> *)routesForPath:(NSString*)path method:(CRHTTPMethod)method
Just make the path lowercase, then call super
.
Practically it would look something like this:
@interface CRHTTPServer()
- (NSArray<CRRouteMatchingResult *> *)routesForPath:(NSString*)path method:(CRHTTPMethod)method;
@end
@interface LowercaseServer : CRHTTPServer
@end
@implementation LowercaseServer
- (NSArray<CRRouteMatchingResult *> *)routesForPath:(NSString*)path method:(CRHTTPMethod)method {
return [super routesForPath:path.lowercaseString method:method];
}
@end