{"id":37167351,"url":"https://github.com/jcyamacho-go/httputil","last_synced_at":"2026-01-14T19:48:30.025Z","repository":{"id":65819042,"uuid":"600614096","full_name":"jcyamacho-go/httputil","owner":"jcyamacho-go","description":"helpers to create http rest services","archived":false,"fork":false,"pushed_at":"2023-03-01T02:14:53.000Z","size":36,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-22T09:52:20.663Z","etag":null,"topics":["error-handling","golang","http","query-params","rest-api"],"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/jcyamacho-go.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":"2023-02-12T02:54:32.000Z","updated_at":"2024-02-20T21:50:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"e908b74e-fcbf-43f9-92ca-ac1bdb23f69c","html_url":"https://github.com/jcyamacho-go/httputil","commit_stats":null,"previous_names":["jcyamacho/httputil"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/jcyamacho-go/httputil","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcyamacho-go%2Fhttputil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcyamacho-go%2Fhttputil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcyamacho-go%2Fhttputil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcyamacho-go%2Fhttputil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcyamacho-go","download_url":"https://codeload.github.com/jcyamacho-go/httputil/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcyamacho-go%2Fhttputil/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28432983,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T18:57:19.464Z","status":"ssl_error","status_checked_at":"2026-01-14T18:52:48.501Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["error-handling","golang","http","query-params","rest-api"],"created_at":"2026-01-14T19:48:29.352Z","updated_at":"2026-01-14T19:48:30.007Z","avatar_url":"https://github.com/jcyamacho-go.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# httputil\n\nhelpers to create http rest services\n\n## features\n\n- bind json body\n- bind form body\n- bind xml body\n- bind query values\n- bind `url.Values`\n- custom **error response writer**\n- write json response\n- write xml response\n- write text response\n- write blob response\n- pprof handler and middleware\n\n## examples\n\n- [example](./example/main.go) project\n\n- handler with json body\n\n```go\nvar ErrBadRequest = httputil.NewHTTPError(http.StatusBadRequest)\n\nfunc CreateTaskHandler(svc TaskService) http.Handler {\n return httputil.NewHandler(func(w http.ResponseWriter, r *http.Request) error {\n  var req CreateTaskRequest\n  if err := httputil.BindJSON(r, \u0026req); err != nil {\n   return ErrBadRequest.WithCause(err)\n  }\n\n  res, err := svc.Create(r.Context(), req)\n  if err != nil {\n   return err\n  }\n\n  return httputil.WriteJSON(w, http.StatusCreated, res)\n })\n}\n```\n\n- handler with query params\n\n```go\nfunc SearchTaskHandler(svc TaskService) http.Handler {\n return httputil.NewHandler(func(w http.ResponseWriter, r *http.Request) error {\n  var req SearchTaskRequest\n  if err := httputil.BindQuery(r, \u0026req, httputil.WithTagName(\"json\")); err != nil {\n   return ErrBadRequest.WithCause(err)\n  }\n\n  res, err := svc.Search(r.Context(), req)\n  if err != nil {\n   return err\n  }\n\n  return httputil.WriteJSON(w, http.StatusOK, res)\n })\n}\n```\n\n- custom error encoder\n\n```go\n\nfunc errorEncoder(w http.ResponseWriter, _ *http.Request, err error) {\n _ = httputil.WriteString(w, http.StatusInternalServerError, err.Error())\n}\n\nfunc CreateTaskHandler(svc TaskService) http.Handler {\n return httputil.NewHandler(func(w http.ResponseWriter, r *http.Request) error {\n  // ...\n }).WithErrorEncoder(errorEncoder)\n}\n\n```\n\n- pprof handler\n\n```go\nr := chi.NewRouter()\nr.Handle(\"/debug/*\", pprof.Handler())\n```\n\n- pprof middleware\n\n```go\nr := chi.NewRouter()\nr.Use(pprof.Middleware)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcyamacho-go%2Fhttputil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcyamacho-go%2Fhttputil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcyamacho-go%2Fhttputil/lists"}