Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GitHubHandler ¶
type GitHubHandler struct {
// contains filtered or unexported fields
}
GitHubHandler proxies requests for GitHub archives following the pattern https://github.com/<user>/<repo>/archive/<hash>.zip or https://github.com/<user>/<repo>/archive/<hash>.tar.gz It returns deterministic archives or GitHub's own server error.
func NewGitHubHandler ¶
func NewGitHubHandler(opts ...Option) *GitHubHandler
NewGitHubHandler creates a new GitHubHandler
func (*GitHubHandler) DefaultSendFile ¶
func (ghh *GitHubHandler) DefaultSendFile(ctx context.Context, uri string, rw http.ResponseWriter, rep *http.Response) error
DefaultSendFile copies the response headers (except content-length, etag and authorization), then recomputes the archive so it is deterministic and streams the result.
func (*GitHubHandler) ServeHTTP ¶
func (ghh *GitHubHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request)
type Option ¶
type Option func(*options) error
Option specializes a handler.
func WithAuthToken ¶
WithAuthToken sets the token to use when requesting tarballs from upstream.
func WithHTTPClient ¶
WithHTTPClient sets the HTTP client to use when requesting the original archive. By default, http.DefaultClient is used which is safe for concurrent use by multiple goroutines.
func WithSendFiler ¶
WithSendFiler controls how the HTTP response is written. Override this to use e.g. caching.