{"id":18752655,"url":"https://github.com/broothie/qst","last_synced_at":"2025-04-13T00:31:21.362Z","repository":{"id":57647915,"uuid":"442872189","full_name":"broothie/qst","owner":"broothie","description":"A Go package for building (and sending) HTTP requests","archived":false,"fork":false,"pushed_at":"2023-06-15T21:37:03.000Z","size":45,"stargazers_count":34,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-26T18:52:11.066Z","etag":null,"topics":["go","golang","http"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/broothie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-29T19:34:43.000Z","updated_at":"2025-02-21T23:08:07.000Z","dependencies_parsed_at":"2024-11-07T17:35:14.392Z","dependency_job_id":null,"html_url":"https://github.com/broothie/qst","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/broothie%2Fqst","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/broothie%2Fqst/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/broothie%2Fqst/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/broothie%2Fqst/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/broothie","download_url":"https://codeload.github.com/broothie/qst/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650590,"owners_count":21139670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","http"],"created_at":"2024-11-07T17:21:41.878Z","updated_at":"2025-04-13T00:31:21.336Z","avatar_url":"https://github.com/broothie.png","language":"Go","readme":"# qst\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/broothie/qst.svg)](https://pkg.go.dev/github.com/broothie/qst)\n[![Go Report Card](https://goreportcard.com/badge/github.com/broothie/qst)](https://goreportcard.com/report/github.com/broothie/qst)\n[![codecov](https://codecov.io/gh/broothie/qst/branch/main/graph/badge.svg?token=CVMUN8Y9FV)](https://codecov.io/gh/broothie/qst)\n[![gosec](https://github.com/broothie/qst/actions/workflows/gosec.yml/badge.svg)](https://github.com/broothie/qst/actions/workflows/gosec.yml)\n\n`qst` is an `*http.Request` builder. \"qst\" is short for \"quest\", which is part of the word \"request\".\n\n## Installation\n\n```shell script\ngo get github.com/broothie/qst\n```\n\n## Documentation\n\nDetailed documentation can be found at [pkg.go.dev](https://pkg.go.dev/github.com/broothie/qst).\n\nA list of all available options can be found [here](https://pkg.go.dev/github.com/broothie/qst#Option).\n\n## Usage\n\n`qst` uses an options pattern to build `*http.Request` objects:\n\n```go\nrequest, err := qst.NewPatch(\"https://breakfast.com/api\", // New PATCH request\n    qst.BearerAuth(\"c0rNfl@k3s\"),                         // Authorization header\n    qst.Path(\"/cereals\", cerealID),                       // Query param\n    qst.BodyJSON(map[string]string{\"name\": \"Life\"}),      // JSON body\n)\n```\n\nIt can also be used to fire requests:\n\n```go\nresponse, err := qst.Patch(\"https://breakfast.com/api\", // Send PATCH request\n    qst.BearerAuth(\"c0rNfl@k3s\"),                       // Authorization header\n    qst.Path(\"/cereals\", cerealID),                     // Query param\n    qst.BodyJSON(map[string]string{\"name\": \"Life\"}),    // JSON body\n)\n```\n\nThe options pattern makes it easy to define custom options:\n\n```go\nfunc createdSinceYesterday() qst.Option {\n    yesterday := time.Now().Add(-24 * time.Hour)\n    return qst.Query(\"created_at\", fmt.Sprintf(\"\u003e%s\", yesterday.Format(time.RFC3339)))\n}\n\nfunc main() {\n    response, err := qst.Get(\"https://breakfast.com/api\",\n        qst.BearerAuth(\"c0rNfl@k3s\"),\n        qst.Path(\"/cereals\"),\n        createdSinceYesterday(),\n    )\n}\n```\n\n### qst.Client\n\nThis package also includes a `Client`, which can be outfitted with a set of default options:\n\n```go\nclient := qst.NewClient(http.DefaultClient,\n    qst.URL(\"https://breakfast.com/api\"),\n    qst.BearerAuth(\"c0rNfl@k3s\"), \n)\n\nresponse, err := client.Patch(\n    // qst.URL(\"https://breakfast.com/api\"), // Not necessary, included via client\n    // qst.BearerAuth(\"c0rNfl@k3s\"),         // Not necessary, included via client\n    qst.Path(\"/cereals\", cerealID),\n    qst.BodyJSON(map[string]interface{}{\n        \"name\": \"Golden Grahams\",\n    }),\n)\n```\n\n### qst.OptionFunc\n\n`OptionFunc` can be used to add a custom function which is run during request creation:\n\n```go\nclient := qst.NewClient(http.DefaultClient,\n    qst.OptionFunc(func(request *http.Request) (*http.Request, error) {\n      token := dynamicallyGetBearerTokenSomehow()\n      return qst.BearerAuth(token).Apply(request)\n    }),\n)\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbroothie%2Fqst","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbroothie%2Fqst","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbroothie%2Fqst/lists"}