Skip to content

Support @Inject of Javalin Context and Helidon ServerRequest/ServerResponse #36

Closed
@rbygrave

Description

@rbygrave

Effectively that means the controllers with these "request scoped dependencies" become request scoped rather than singleton scoped. dinject will detect this and generate BeanFactory class to match and these will be used by the generated web route.

@Controller
@Path("/req-scoped")
class ReqScopedController {

  @Inject
  Context context;   // inject the Javalin context (so will be treated as request scoped)

  @Produces("text/plain")
  @Get
  String getSimple() {
    return context.url();
  }
}

For Helidon

@Controller
@Path("/req-scoped")
public class ReqScopedController {

  @Inject
  ServerRequest request;  // inject helidon request

  @Inject
  ServerResponse response;  // inject helidon response 
  ...
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions