google / google/go-github

Proposal: Make preview features configurable

Aperta
#999 17 commenti 1 reazione 0 assegnatari Vedi su GitHub
NeedsInvestigation
Lingua principale
Go
Stelle
11.3k
Fork
2.5k
Merge medio
1g 20h
PR unite (30g)
52

Descrizione

## Problem

A project I'm working on has an issue where a list of repos is returning a Server Error due to an additional `Accept` header being added (The "mediaTypeCodesOfConductPreview" header).

Removing this header fixes the problem but I can't do this with the current library implementation.

## Solution

Instead of adding these headers by default, we could move them to an Options parameter similar to ListOptions.

```go
type RequestOptions {
acceptHeaders []string
}
```

### Pros

- Allows developers to control which headers to add (including headers the library may not control)
- Removes the maintenance of adding / removing headers from library owners
- Opens the door for any additional request options in the future.
- This will remove the need for comments like `// TODO: remove custom Accept headers when APIs fully launch.`

### Cons

- Forces users to care about headers
- While a con, users should know if a feature they are using is preview or not and subject to change

## Concerns

The only major concern I have with this is approach is that it gets fuzzy what to do with entirely new API's (for example the checks API).

For consistency the API could still require the developer to add the header.
For a sane API the API could add the header with the expectation that the header is removed as soon as possible, but again moves the burden on to the library.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start by tracing how default preview Accept headers and ListOptions are handled; the issue names no files or tests. Define the RequestOptions API and resolve how new APIs should handle preview headers, then verify that repository-list requests can omit the unwanted header.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
go
Ambito
api
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.