generated from fluffy-bunny/fluffycore-grpc-starterkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
swagger.go
43 lines (37 loc) · 1.02 KB
/
swagger.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package swagger
import (
di "github.com/fluffy-bunny/fluffy-dozm-di"
wellknown_echo "github.com/fluffy-bunny/fluffycore-rage-identity/pkg/wellknown/echo"
contracts_handler "github.com/fluffy-bunny/fluffycore/echo/contracts/handler"
echo "github.com/labstack/echo/v4"
echoSwagger "github.com/swaggo/echo-swagger"
)
type (
service struct {
swaggerFunc echo.HandlerFunc
}
)
func init() {
var _ contracts_handler.IHandler = (*service)(nil)
}
// AddScopedIHandler registers the *service as a singleton.
func AddScopedIHandler(builder di.ContainerBuilder) {
contracts_handler.AddScopedIHandleWithMetadata[*service](builder,
ctor,
[]contracts_handler.HTTPVERB{
contracts_handler.GET,
},
wellknown_echo.SwaggerPath,
)
}
func ctor() (*service, error) {
return &service{
swaggerFunc: echoSwagger.WrapHandler,
}, nil
}
func (s *service) GetMiddleware() []echo.MiddlewareFunc {
return []echo.MiddlewareFunc{}
}
func (s *service) Do(c echo.Context) error {
return s.swaggerFunc(c)
}