{"action":"created","issue":{"url":"https://api.github.com/repos/p-meier/hapi-api-version/issues/11","repository_url":"https://api.github.com/repos/p-meier/hapi-api-version","labels_url":"https://api.github.com/repos/p-meier/hapi-api-version/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/p-meier/hapi-api-version/issues/11/comments","events_url":"https://api.github.com/repos/p-meier/hapi-api-version/issues/11/events","html_url":"https://github.com/p-meier/hapi-api-version/pull/11","id":159955842,"number":11,"title":"Added support for a dynamic, parameterized basePath","user":{"login":"wk76","id":10880990,"avatar_url":"https://avatars.githubusercontent.com/u/10880990?v=3","gravatar_id":"","url":"https://api.github.com/users/wk76","html_url":"https://github.com/wk76","followers_url":"https://api.github.com/users/wk76/followers","following_url":"https://api.github.com/users/wk76/following{/other_user}","gists_url":"https://api.github.com/users/wk76/gists{/gist_id}","starred_url":"https://api.github.com/users/wk76/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wk76/subscriptions","organizations_url":"https://api.github.com/users/wk76/orgs","repos_url":"https://api.github.com/users/wk76/repos","events_url":"https://api.github.com/users/wk76/events{/privacy}","received_events_url":"https://api.github.com/users/wk76/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-06-13T13:54:51Z","updated_at":"2016-06-15T09:46:20Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/p-meier/hapi-api-version/pulls/11","html_url":"https://github.com/p-meier/hapi-api-version/pull/11","diff_url":"https://github.com/p-meier/hapi-api-version/pull/11.diff","patch_url":"https://github.com/p-meier/hapi-api-version/pull/11.patch"},"body":"Hi. I have created a pull request for a feature that I need. You are free to review the code, make changes or suggestions, or to drop the feature completely if you think it's a contribution that people will not generally find useful. I thought I'd just give you the option, in case you wanted to include it. I am happy to keep my changes in a separate fork, but obviously it would be first prize to have the feature supported officially.\r\n\r\nThe context for the feature is that I want to build a tenant aware API, and so have configured my Hapi URL's to look like /{tenant}/v1/some_api_call, which can be called, from a client, by using /tenant_abc/some_api_call or /tenant_xyz/some_api_call. This is obviously slightly different from having a fixed basePath, since the tenant ID I get from the call will vary from tenant to tenant.\r\n\r\nWhen reviewing the code, bear in mind that I am new to both Javascript and Hapi JS. Coming from a Java background, this is my first real project in JS, so the code might not be optimal, and slightly more verbose than necessary. I tried to add the feature in such a way that the existing code path has the most minimal amount of change, and the added code will only be invoked if a dynamic basePath is detected. \r\n\r\nEither way, thanks. Appreciate your work.\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/p-meier/hapi-api-version/issues/comments/226139717","html_url":"https://github.com/p-meier/hapi-api-version/pull/11#issuecomment-226139717","issue_url":"https://api.github.com/repos/p-meier/hapi-api-version/issues/11","id":226139717,"user":{"login":"wk76","id":10880990,"avatar_url":"https://avatars.githubusercontent.com/u/10880990?v=3","gravatar_id":"","url":"https://api.github.com/users/wk76","html_url":"https://github.com/wk76","followers_url":"https://api.github.com/users/wk76/followers","following_url":"https://api.github.com/users/wk76/following{/other_user}","gists_url":"https://api.github.com/users/wk76/gists{/gist_id}","starred_url":"https://api.github.com/users/wk76/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wk76/subscriptions","organizations_url":"https://api.github.com/users/wk76/orgs","repos_url":"https://api.github.com/users/wk76/repos","events_url":"https://api.github.com/users/wk76/events{/privacy}","received_events_url":"https://api.github.com/users/wk76/received_events","type":"User","site_admin":false},"created_at":"2016-06-15T09:46:20Z","updated_at":"2016-06-15T09:46:20Z","body":"Hi, no problem taking your time, my stuff currently works, so no pressure from this side. Yes, you understand the problem right. In Hapi I have configured a route, for example, like such as /{tenant}/users/{user}, so that when they make a call to the API, the URL would look like /tenant_abc/users/user_xyz\r\n\r\nThe values for tenant (tenant_abc) and user (user_xyz) is what I retrieve from the request.params. If I want to introduce versioning, I can either take the approach /v1/{tenant}/users and no changes would be required. Of course, I'd prefer to rather go with /{tenant}/v1/users, which means I need to treat the {tenant} as a basePath in hapi-api-version, except that I can receive any value on that path, so need to put that value back in the final URL.\r\n\r\nHope that makes sense.\r\n\r\nI understand that it's a pretty unique feature, and once in the code it has to be supported, so really, only include it if you feel it is of benefit to the project. The check that I use to determine whether it is a dynamic basePath value is a very rudimentary one at this point, and if the check is false, then everything else is pretty much unchanged."}}
{"actor":{"display_login":"wk76"}}