{"action":"created","issue":{"url":"https://api.github.com/repos/bustoutsolutions/siesta/issues/47","repository_url":"https://api.github.com/repos/bustoutsolutions/siesta","labels_url":"https://api.github.com/repos/bustoutsolutions/siesta/issues/47/labels{/name}","comments_url":"https://api.github.com/repos/bustoutsolutions/siesta/issues/47/comments","events_url":"https://api.github.com/repos/bustoutsolutions/siesta/issues/47/events","html_url":"https://github.com/bustoutsolutions/siesta/issues/47","id":146420986,"number":47,"title":"Better URL Pattern Matching","user":{"login":"MPiccinato","id":72162,"avatar_url":"https://avatars.githubusercontent.com/u/72162?v=3","gravatar_id":"","url":"https://api.github.com/users/MPiccinato","html_url":"https://github.com/MPiccinato","followers_url":"https://api.github.com/users/MPiccinato/followers","following_url":"https://api.github.com/users/MPiccinato/following{/other_user}","gists_url":"https://api.github.com/users/MPiccinato/gists{/gist_id}","starred_url":"https://api.github.com/users/MPiccinato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MPiccinato/subscriptions","organizations_url":"https://api.github.com/users/MPiccinato/orgs","repos_url":"https://api.github.com/users/MPiccinato/repos","events_url":"https://api.github.com/users/MPiccinato/events{/privacy}","received_events_url":"https://api.github.com/users/MPiccinato/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-04-06T20:15:32Z","updated_at":"2016-04-19T10:14:39Z","closed_at":null,"body":"I have setup a handful of routes such as: \r\n\r\n```\r\n api.configureTransformer(\"/products/filters\") { returns Filter }\r\n api.configureTransformer(\"/products/*\") { returns Product }\r\n api.configureTransformer(\"/products/*/market\") { returns Market }\r\n```\r\n\r\nWhen the '/products/filters' resource is loaded it handles it then passes 'Filter' objects into the 'products/*' handler which expects a JSON (SwiftyJSON) object. So of course the 'WrongTypeInTranformerPipeline' error pops up.\r\n\r\nIt would be nice to either allow a ResponseTransformer to say \"no more transforming, we are done\" or allow for better pattern matching in the URLs such as specifying the wildcard item should be an INT."},"comment":{"url":"https://api.github.com/repos/bustoutsolutions/siesta/issues/comments/211843134","html_url":"https://github.com/bustoutsolutions/siesta/issues/47#issuecomment-211843134","issue_url":"https://api.github.com/repos/bustoutsolutions/siesta/issues/47","id":211843134,"user":{"login":"enricode","id":3370749,"avatar_url":"https://avatars.githubusercontent.com/u/3370749?v=3","gravatar_id":"","url":"https://api.github.com/users/enricode","html_url":"https://github.com/enricode","followers_url":"https://api.github.com/users/enricode/followers","following_url":"https://api.github.com/users/enricode/following{/other_user}","gists_url":"https://api.github.com/users/enricode/gists{/gist_id}","starred_url":"https://api.github.com/users/enricode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/enricode/subscriptions","organizations_url":"https://api.github.com/users/enricode/orgs","repos_url":"https://api.github.com/users/enricode/repos","events_url":"https://api.github.com/users/enricode/events{/privacy}","received_events_url":"https://api.github.com/users/enricode/received_events","type":"User","site_admin":false},"created_at":"2016-04-19T10:14:39Z","updated_at":"2016-04-19T10:14:39Z","body":"I'm running in a simpler problem that maybe has already a solution that I can't see.\r\n\r\nI have two endpoints:\r\n- products/\r\n- products/[id]\r\n\r\nConfiguring them like: \r\n```\r\nservice.configureTransformer(\"products/\") {\r\n...\r\n}\r\nservice.configureTransformer(\"products/*\") {\r\n...\r\n}\r\n```\r\nSiesta catches the latter also on \"products/\" call (and it's correct, I think).\r\nChanging the endpoint \"products/\" to \"products\" brings an OAuth 401 because Authorization header isn't added to request and I don't really know why (maybe it's a bug?)*\r\n\r\nSo the only solution that came to my mind was:\r\n\r\n```\r\nservice.configureTransformer(ProductIntPattern()) { ... }\r\n\r\nstruct ProductIntPattern: ConfigurationPatternConvertible\r\n{\r\n  func configurationPattern(service: Service) -> NSURL -> Bool {\r\n    return {\r\n      if let components = $0.pathComponents where components.count > 1 {\r\n        return (components[components.count - 2] == \"products\" && Int(components.last!) != nil)\r\n      }\r\n      return false\r\n    }\r\n  }\r\n  var configurationPatternDescription: String {\r\n    return \"\"\r\n  }\r\n}\r\n```\r\n\r\nThat really isn't so good as something like:\r\n`service.configureTransformer(\"products/:id\")`\r\n\r\n\r\n---\r\n\\* authorization is configured in this way\r\n```\r\nservice.configure {\r\n  $0.config.headers[\"Authorization\"] = self.authHeader\r\n}\r\n```"}}