CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/golang-github-com-google-go-github

Go client library for accessing the GitHub API v3

Overall
score

65%

Overview
Eval results
Files

task.mdevals/scenario-2/

GitHub Request Factory

Build a helper that uses the GitHub Go SDK dependency to construct ready-to-send requests for JSON endpoints, form-encoded exchanges, and binary uploads. Leverage the dependency's request-building helpers rather than crafting raw HTTP requests manually.

Capabilities

JSON discussion creation

  • Building a request for creating a discussion post uses the API base URL, includes owner/repo path, and JSON encodes title and body fields. @test
  • The request sets GitHub API version and preview Accept headers when provided. @test

Form token exchange

  • Building a request for exchanging an OAuth code sends client_id, client_secret, code, and redirect_uri as form-encoded fields (including optional state) with a JSON response expected. @test

Release asset upload

  • Building an upload request targets the upload base URL with name and optional label query parameters, uses the provided media type, and streams the provided reader with the declared size. @test
  • The upload request does not reuse the API host when an upload URL is provided. @test

Implementation

@generates

API

type RequestFactory struct {
    Client interface {
        Do(req *http.Request) (*http.Response, error)
    }
    APIBaseURL    string
    UploadBaseURL string
    Token         string
    APIVersion    string
}

func NewRequestFactory(client interface{ Do(req *http.Request) (*http.Response, error) }, apiBaseURL, uploadBaseURL, token, apiVersion string) *RequestFactory

func (f *RequestFactory) BuildJSONDiscussionRequest(ctx context.Context, owner, repo, title, body, previewAccept string) (*http.Request, error)

func (f *RequestFactory) BuildFormTokenRequest(ctx context.Context, clientID, clientSecret, code, redirectURI, state string) (*http.Request, error)

func (f *RequestFactory) BuildUploadAssetRequest(ctx context.Context, uploadURL, fileName, label, mediaType string, content io.ReadSeeker, size int64) (*http.Request, error)

Dependencies { .dependencies }

github.com/google/go-github/v80/github { .dependency }

Provides helpers for constructing GitHub REST and upload requests.

Install with Tessl CLI

npx tessl i tessl/golang-github-com-google-go-github

tile.json