Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gmgigi96 committed Nov 9, 2021
1 parent 7b5ebe6 commit 01a37b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/ctx/agentctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func ContextGetUserAgent(ctx context.Context) (*ua.UserAgent, bool) {
return nil, false
}

// ContextGetUserAgentString returns the user agent string if set in the given context.
func ContextGetUserAgentString(ctx context.Context) (string, bool) {
md, ok := metadata.FromIncomingContext(ctx)
if !ok {
Expand Down
4 changes: 3 additions & 1 deletion pkg/useragent/useragent.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func isGRPC(ua *ua.UserAgent) bool {
return strings.HasPrefix(ua.Name, "grpc")
}

// GetCategory returns the category of the user agent
// getCategory returns the category of the user agent
// (i.e. if it is a web, mobile, desktop or grpc user agent)
func getCategory(ua *ua.UserAgent) string {
switch {
Expand All @@ -64,6 +64,8 @@ func getCategory(ua *ua.UserAgent) string {
}
}

// IsUserAgentAllowed return true if the user agent corresponds
// to one in the allowed user agents list
func IsUserAgentAllowed(ua *ua.UserAgent, allowedUserAgents []string) bool {
cat := getCategory(ua)
for _, userAgent := range allowedUserAgents {
Expand Down

0 comments on commit 01a37b6

Please sign in to comment.