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

Acabar com repetições de parâmetros na URL na API #40

Open
GuilhermeFreire opened this issue Jun 14, 2020 · 0 comments
Open

Acabar com repetições de parâmetros na URL na API #40

GuilhermeFreire opened this issue Jun 14, 2020 · 0 comments
Labels
backend Related to the backend bug Something isn't working

Comments

@GuilhermeFreire
Copy link
Collaborator

Atualmente a API utiliza multiplas instâncias do mesmo parâmetro para criar "listas" usando o método GET.

tickers, ok := ctx.QueryParams()["tickers"]

E. g. localhost:8080/fetch_latest_prices?tickers=ITSA4&tickers=SQIA3 resultaria no backend recebendo uma variável tickers do tipo String[] com o valor ["ITSA4", "SQIA3"].

Isso entretanto não é recomendável, pois diferentes parsers de URL adotam diferentes estratégias pra lidar com repetições de parâmetros do GET. No caso dessa que estamos usando pra API, ele devolve o valor de todas as instâncias do parâmetro em uma lista. Entretanto esse comportamento não é ubíquo. Muito pelo contrário, cada biblioteca interpreta de um jeito. Isso pode se tornar problemático e perigoso se resolvermos mudar de biblioteca para receber requests da API, se resolvermos colocar outro parser na frente da API (e.g. load balancer), entre oturos.

Isso eventualmente deve ser corrigido para garantir estabilidade e segurança do serviço. Uma solução simples seria mudar o endpoint para receber uma lista via POST.

@GuilhermeFreire GuilhermeFreire added bug Something isn't working backend Related to the backend labels Jun 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Related to the backend bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant