Browse Source

Container: add WithContainer helper

extension
wpetit 1 year ago
parent
commit
f48503f2b6
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      middleware/container/service_container.go

+ 6
- 0
middleware/container/service_container.go 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)
}

Loading…
Cancel
Save