Container: add WithContainer helper

This commit is contained in:
wpetit 2020-07-07 08:19:51 +02:00
parent 5d53e32316
commit f48503f2b6

View File

@ -41,3 +41,9 @@ func Must(ctx context.Context) *service.Container {
func ServiceContainer(container *service.Container) goweb.Middleware {
return middleware.WithValue(KeyServiceContainer, container)
}
// WithContainer returns a new context.Context with the given *service.Container
// attached.
func WithContainer(ctx context.Context, container *service.Container) context.Context {
return context.WithValue(ctx, KeyServiceContainer, container)
}