Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update generateRequest to include User-Agent #3

Merged
merged 1 commit into from
Apr 4, 2024
Merged

Update generateRequest to include User-Agent #3

merged 1 commit into from
Apr 4, 2024

Conversation

chatterchats
Copy link
Contributor

@chatterchats chatterchats commented Apr 4, 2024

resolves #4

Hey there! Just stopped by to give a small update to your generateRequest method to have a User-Agent field to better specify where requests are coming from

@Millefeuille42 Millefeuille42 changed the base branch from master to develop April 4, 2024 07:46
@Millefeuille42
Copy link
Owner

Millefeuille42 commented Apr 4, 2024

Thanks a lot for this ! Indeed it would be better to add it, however this might indicate more "which" is used more than "who/where" since anybody could clone this and run it.

To prevent this, I would add something like

	userAgent := "Helldivers II Tools"
	if os.Getenv("HDII__GENERIC__USER_AGENT") != "" {
		userAgent = fmt.Sprintf("%s - %s", userAgent, os.Getenv("HDII__GENERIC__USER_AGENT"))
	}
	req.Header.Set("User-Agent", userAgent)

And to capitalize on this, add these elements in the docker-compose file

  bot:
    [...]
    environment:
      - HDII__GENERIC__USER_AGENT=${HDII__GENERIC__USER_AGENT-docker}-bot

(for all of the services of course)

This way it can be easily identified which service is doing the requests in the event one would expose the API, and people deploying the API can specify their own "id".

I'll merge it and add these elements later.

Thanks again !

@Millefeuille42 Millefeuille42 merged commit 5e48528 into Millefeuille42:develop Apr 4, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update requests to have User-Agent field
2 participants