Gin: Gin-way dependency injection

Created on 4 Jan 2018  路  1Comment  路  Source: gin-gonic/gin

What is the better way inject services?
Database for example, template-cache, etc.
Should I use gin.Context.Keys via middlewares or Use gin.HandlerFunc as struct such as controller in MVC.
What are you thinking about including it in doc for DI or testing example?

I think that context wasn't maked for dependencies and inject to struct actually looks more friendly.

>All comments

I usually inject services through middleware and context. Simple and easy to debug / extend.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mdnight picture mdnight  路  3Comments

iiinsomnia picture iiinsomnia  路  3Comments

frederikhors picture frederikhors  路  3Comments

ghost picture ghost  路  3Comments

gplume picture gplume  路  3Comments