|
@@ -3,7 +3,6 @@ package middleware
|
|
|
import (
|
|
|
"context"
|
|
|
"fmt"
|
|
|
- "github.com/gofrs/uuid"
|
|
|
"github.com/labstack/echo/v4"
|
|
|
"net/http"
|
|
|
)
|
|
@@ -16,23 +15,18 @@ func InstanceId() echo.MiddlewareFunc {
|
|
|
return echo.NewHTTPError(http.StatusForbidden, "missing or malformed instance id")
|
|
|
}
|
|
|
|
|
|
- id, err := uuid.FromString(s)
|
|
|
- if err != nil {
|
|
|
- return echo.NewHTTPError(http.StatusForbidden, "missing or malformed instance id")
|
|
|
- }
|
|
|
-
|
|
|
- value := context.WithValue(c.Request().Context(), keyInstanceId, id)
|
|
|
+ value := context.WithValue(c.Request().Context(), keyInstanceId, s)
|
|
|
c.SetRequest(c.Request().WithContext(value))
|
|
|
return next(c)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func GetInstanceId(ctx context.Context) (uuid.UUID, error) {
|
|
|
- id, ok := ctx.Value(keyInstanceId).(uuid.UUID)
|
|
|
+func GetInstanceId(ctx context.Context) (*string, error) {
|
|
|
+ id, ok := ctx.Value(keyInstanceId).(string)
|
|
|
if !ok {
|
|
|
- return uuid.Nil, fmt.Errorf("missing or malformed instance id")
|
|
|
+ return nil, fmt.Errorf("missing or malformed instance id")
|
|
|
}
|
|
|
|
|
|
- return id, nil
|
|
|
+ return &id, nil
|
|
|
}
|