refactor: move vault package to app directory

This commit is contained in:
Prad Nukala
2024-12-09 18:39:57 -05:00
parent c158904efc
commit e3b8f2cffe
46 changed files with 15 additions and 15 deletions
+35
View File
@@ -0,0 +1,35 @@
package resolver
import (
"net/http"
"github.com/labstack/echo/v4"
"github.com/onsonr/sonr/app/gateway/config"
"google.golang.org/grpc"
)
type ClientsContext struct {
echo.Context
addr string
}
func GetClientConn(c echo.Context) (*grpc.ClientConn, error) {
cc, ok := c.(*ClientsContext)
if !ok {
return nil, echo.NewHTTPError(http.StatusInternalServerError, "ClientsContext not found")
}
grpcConn, err := grpc.NewClient(cc.addr, grpc.WithInsecure())
if err != nil {
return nil, echo.NewHTTPError(http.StatusInternalServerError, "Failed to dial gRPC")
}
return grpcConn, nil
}
func Middleware(env config.Env) echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
cc := &ClientsContext{Context: c, addr: env.GetSonrGrpcUrl()}
return next(cc)
}
}
}