@rivascva/dt-idl 1.1.94 → 1.1.96

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/go/auth/utils.go CHANGED
@@ -33,8 +33,8 @@ func CanActorAccessResourcesForUser(ctx context.Context, userId string) (bool, e
33
33
  }
34
34
  }
35
35
 
36
- // CanActorAccessResourcesForAll checks if the actor is allowed to access resources for all users.
37
- func CanActorAccessResourcesForAll(ctx context.Context) (bool, error) {
36
+ // CanActorAccessAllResources checks if the actor is allowed to access all resources.
37
+ func CanActorAccessAllResources(ctx context.Context) (bool, error) {
38
38
  // get the actor id from the context
39
39
  actorId, err := utils.GetActorIdFromContext(ctx)
40
40
  if err != nil {
@@ -47,7 +47,7 @@ func CanActorAccessResourcesForAll(ctx context.Context) (bool, error) {
47
47
  return false, fmt.Errorf("failed to get the token type from the context: %w", err)
48
48
  }
49
49
 
50
- // check if the actor is allowed to access the user id
50
+ // check if the actor is a service
51
51
  switch tokenType {
52
52
  case "user":
53
53
  return false, nil
package/go/log/utils.go CHANGED
@@ -59,6 +59,11 @@ func toJson(ctx context.Context, m any, kvs map[string]any, lvl string) string {
59
59
  out["requestPath"] = requestPath
60
60
  }
61
61
 
62
+ // add the request method
63
+ if requestMethod, err := utils.GetRequestMethodFromContext(ctx); err == nil {
64
+ out["requestMethod"] = requestMethod
65
+ }
66
+
62
67
  // add the request id
63
68
  if requestId, err := utils.GetRequestIdFromContext(ctx); err == nil {
64
69
  out["requestId"] = requestId
@@ -67,6 +67,9 @@ func CommonContext(next http.Handler) http.Handler {
67
67
  // set the request path in the request context
68
68
  ctx = context.WithValue(ctx, models.RequestPathKey, r.URL.Path)
69
69
 
70
+ // set the request method in the request context
71
+ ctx = context.WithValue(ctx, models.RequestMethodKey, r.Method)
72
+
70
73
  r = r.WithContext(ctx)
71
74
  next.ServeHTTP(w, r)
72
75
  })
@@ -8,6 +8,8 @@ const (
8
8
  TokenKey = ContextKey("token")
9
9
  // RequestPathKey is the key used to set/get the request path in the request context.
10
10
  RequestPathKey = ContextKey("requestPath")
11
+ // RequestMethodKey is the key used to set/get the request method in the request context.
12
+ RequestMethodKey = ContextKey("requestMethod")
11
13
  // RequestIdKey is the key used to set/get the request id in the request context.
12
14
  RequestIdKey = ContextKey("requestId")
13
15
  )
@@ -66,6 +66,15 @@ func GetRequestPathFromContext(ctx context.Context) (string, error) {
66
66
  return requestPath, nil
67
67
  }
68
68
 
69
+ // GetRequestMethodFromContext retrieves the request method from the given context.
70
+ func GetRequestMethodFromContext(ctx context.Context) (string, error) {
71
+ requestMethod, ok := ctx.Value(models.RequestMethodKey).(string)
72
+ if !ok {
73
+ return "", errors.New("request method not found in the context")
74
+ }
75
+ return requestMethod, nil
76
+ }
77
+
69
78
  // GetRequestIdFromContext retrieves the request id from the given context.
70
79
  func GetRequestIdFromContext(ctx context.Context) (string, error) {
71
80
  requestId, ok := ctx.Value(models.RequestIdKey).(string)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rivascva/dt-idl",
3
- "version": "1.1.94",
3
+ "version": "1.1.96",
4
4
  "description": "Dream Trade - Interface Definition Language",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",