Please refer me to the documentation to investigate which services I could retrive from @Context annotation in REST.
In detail.
I have POST function like this:
@POST @Produces(RestUtils.APPLICATION_JSON_UTF8)
public String postFunc( @Context Settings settings) {
pluginSettings.add(settings.getString("some-key")); return <some String>; }
I want to retrive smth like Settings or RepositoryHookContext, how could I achieve it?
Community moderators have prevented the ability to post new answers.
Hi Dana,
The @Context annotation is used to lookup Stash objects based on the URL. For example "@Context Project project" will lookup the project based on the URL "projects/{projectKey}".
All of the items which Stash provides for use with the @Context annotation extend the class com.atlassian.stash.internal.rest.inject.AbstractResourceInjectable if you want to take a look to see what is injectable.
For adding your own injectable you would need to write your own Jersey InjectableProvider. Note that this would be a low level change and not part of the Stash public API and so is subject to change/breakage in the future.
I would suggest it would be easier to just supply plain parameters to your REST endpoints and do your lookups in the service layer.
Regards,
Tom.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.