From e24abdecf92e7d42994f2907fa39ed426e29a6f0 Mon Sep 17 00:00:00 2001 From: Luke Young Date: Fri, 7 Feb 2025 19:19:43 -0800 Subject: [PATCH 1/6] Update README.md --- README.md | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d922918263c..8a32f89b24f 100644 --- a/README.md +++ b/README.md @@ -257,22 +257,28 @@ if _, ok := err.(*github.AcceptedError); ok { ### Conditional Requests ### -The GitHub API has good support for conditional requests which will help -prevent you from burning through your rate limit, as well as help speed up your -application. `go-github` does not handle conditional requests directly, but is -instead designed to work with a caching `http.Transport`. We recommend using -[gregjones/httpcache](https://github.com/gregjones/httpcache) for that. For example: +The GitHub REST API has good support for [conditional HTTP requests](https://docs.github.com/en/rest/using-the-rest-api/best-practices-for-using-the-rest-api?apiVersion=2022-11-28#use-conditional-requests-if-appropriate) +via the `ETag` header which will help prevent you from burning through your +rate limit, as well as help speed up your application. `go-github` does not +handle conditional requests directly, but is instead designed to work with a +caching `http.Transport`. + +Typically, a [RFC 7234](https://datatracker.ietf.org/doc/html/rfc7234) +compliant HTTP cache such as [gregjones/httpcache](https://github.com/gregjones/httpcache) +is recommended, ex: ```go import "github.com/gregjones/httpcache" - client := github.NewClient( - httpcache.NewMemoryCacheTransport().Client() - ).WithAuthToken(os.Getenv("GITHUB_TOKEN")) +client := github.NewClient( + httpcache.NewMemoryCacheTransport().Client() +).WithAuthToken(os.Getenv("GITHUB_TOKEN")) ``` -Learn more about GitHub conditional requests in -["Use conditional requests if appropriate"](https://docs.github.com/en/rest/using-the-rest-api/best-practices-for-using-the-rest-api?apiVersion=2022-11-28#use-conditional-requests-if-appropriate). +Alternatively, the [bored-engineer/github-conditional-http-transport](https://github.com/bored-engineer/github-conditional-http-transport) +package relies on (undocumented) GitHub specific cache logic and is +recommended when making requests using short-lived credentials such as a +[GitHub App installation token](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app-installation). ### Creating and Updating Resources ### From 05bfb6ab1b44bf25f38adc4c3961c7d5da2770e5 Mon Sep 17 00:00:00 2001 From: Luke Young Date: Fri, 7 Feb 2025 19:22:26 -0800 Subject: [PATCH 2/6] Update doc.go --- github/doc.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/github/doc.go b/github/doc.go index 4deb94c7356..73ab17d5819 100644 --- a/github/doc.go +++ b/github/doc.go @@ -138,11 +138,17 @@ To detect this condition of error, you can check if its type is # Conditional Requests -The GitHub API has good support for conditional requests which will help -prevent you from burning through your rate limit, as well as help speed up your -application. go-github does not handle conditional requests directly, but is -instead designed to work with a caching http.Transport. We recommend using -https://github.com/gregjones/httpcache for that. +The GitHub REST API has good support for conditional HTTP requests +via the `ETag` header which will help prevent you from burning through your +rate limit, as well as help speed up your application. `go-github` does not +handle conditional requests directly, but is instead designed to work with a +caching `http.Transport`. + +Typically, a RFC 7234 compliant HTTP cache such as https://github.com/gregjones/httpcache +is recommended. Alternatively, the https://github.com/bored-engineer/github-conditional-http-transport +package relies on (undocumented) GitHub specific cache logic and is +recommended when making requests using short-lived credentials such as a +GitHub App installation token. Learn more about GitHub conditional requests at https://docs.github.com/rest/overview/resources-in-the-rest-api#conditional-requests. From edef7e14312bdee179c19577d9a80cc3ed61f3dc Mon Sep 17 00:00:00 2001 From: Luke Young Date: Fri, 7 Feb 2025 19:24:21 -0800 Subject: [PATCH 3/6] Update doc.go --- github/doc.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/github/doc.go b/github/doc.go index 73ab17d5819..8575142a6aa 100644 --- a/github/doc.go +++ b/github/doc.go @@ -139,10 +139,10 @@ To detect this condition of error, you can check if its type is # Conditional Requests The GitHub REST API has good support for conditional HTTP requests -via the `ETag` header which will help prevent you from burning through your -rate limit, as well as help speed up your application. `go-github` does not +via the ETag header which will help prevent you from burning through your +rate limit, as well as help speed up your application. go-github does not handle conditional requests directly, but is instead designed to work with a -caching `http.Transport`. +caching http.Transport. Typically, a RFC 7234 compliant HTTP cache such as https://github.com/gregjones/httpcache is recommended. Alternatively, the https://github.com/bored-engineer/github-conditional-http-transport From 64c19507b9e4e42d92bbe583c507170d415a9f6b Mon Sep 17 00:00:00 2001 From: Luke Young Date: Sat, 8 Feb 2025 10:11:20 -0800 Subject: [PATCH 4/6] go generate ./... --- github/doc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/doc.go b/github/doc.go index 8575142a6aa..6c0960ebe1b 100644 --- a/github/doc.go +++ b/github/doc.go @@ -147,7 +147,7 @@ caching http.Transport. Typically, a RFC 7234 compliant HTTP cache such as https://github.com/gregjones/httpcache is recommended. Alternatively, the https://github.com/bored-engineer/github-conditional-http-transport package relies on (undocumented) GitHub specific cache logic and is -recommended when making requests using short-lived credentials such as a +recommended when making requests using short-lived credentials such as a GitHub App installation token. Learn more about GitHub conditional requests at From 386ec6044c9a5db89b804bbc3b71994416180377 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Sat, 8 Feb 2025 15:34:52 -0500 Subject: [PATCH 5/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8a32f89b24f..378e801f394 100644 --- a/README.md +++ b/README.md @@ -263,7 +263,7 @@ rate limit, as well as help speed up your application. `go-github` does not handle conditional requests directly, but is instead designed to work with a caching `http.Transport`. -Typically, a [RFC 7234](https://datatracker.ietf.org/doc/html/rfc7234) +Typically, an [RFC 7234](https://datatracker.ietf.org/doc/html/rfc7234) compliant HTTP cache such as [gregjones/httpcache](https://github.com/gregjones/httpcache) is recommended, ex: From 6db7e25a5ec087f87b1b982ac3ba0433c63060f3 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Sat, 8 Feb 2025 15:35:12 -0500 Subject: [PATCH 6/6] Update github/doc.go --- github/doc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/doc.go b/github/doc.go index 6c0960ebe1b..79d92d9ee07 100644 --- a/github/doc.go +++ b/github/doc.go @@ -144,7 +144,7 @@ rate limit, as well as help speed up your application. go-github does not handle conditional requests directly, but is instead designed to work with a caching http.Transport. -Typically, a RFC 7234 compliant HTTP cache such as https://github.com/gregjones/httpcache +Typically, an RFC 7234 compliant HTTP cache such as https://github.com/gregjones/httpcache is recommended. Alternatively, the https://github.com/bored-engineer/github-conditional-http-transport package relies on (undocumented) GitHub specific cache logic and is recommended when making requests using short-lived credentials such as a