{"id":27299861,"url":"https://github.com/clavoie/httpu","last_synced_at":"2025-04-12T00:49:50.509Z","repository":{"id":57519190,"uuid":"145708560","full_name":"clavoie/httpu","owner":"clavoie","description":"Http handler utilities for Go","archived":false,"fork":false,"pushed_at":"2020-03-21T18:15:06.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T00:49:42.701Z","etag":null,"topics":["go","golang","http-handler","utilities"],"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/clavoie.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}},"created_at":"2018-08-22T12:50:33.000Z","updated_at":"2020-03-21T18:14:46.000Z","dependencies_parsed_at":"2022-09-06T03:42:31.510Z","dependency_job_id":null,"html_url":"https://github.com/clavoie/httpu","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clavoie%2Fhttpu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clavoie%2Fhttpu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clavoie%2Fhttpu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clavoie%2Fhttpu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clavoie","download_url":"https://codeload.github.com/clavoie/httpu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248501911,"owners_count":21114681,"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-handler","utilities"],"created_at":"2025-04-12T00:49:49.819Z","updated_at":"2025-04-12T00:49:50.494Z","avatar_url":"https://github.com/clavoie.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# httpu [![GoDoc](https://godoc.org/github.com/clavoie/httpu?status.svg)](http://godoc.org/github.com/clavoie/httpu) [![Build Status](https://travis-ci.org/clavoie/httpu.svg?branch=master)](https://travis-ci.org/clavoie/httpu) [![codecov](https://codecov.io/gh/clavoie/httpu/branch/master/graph/badge.svg)](https://codecov.io/gh/clavoie/httpu) [![Go Report Card](https://goreportcard.com/badge/github.com/clavoie/httpu)](https://goreportcard.com/report/github.com/clavoie/httpu)\n\nHttp handler utilities for Go.\n\nhttpu provides several convenience functions to remove some of the boilerplate from top level http handlers:\n\n```go\nfunc Handler(w http.ResponseWriter, r *http.Request) {\n  request := new(MyRequest)\n  \n  if httpu.DecodeJsonOr400(w, r, request, \"Could not decode request\") {\n    // http.StatusBadRequest has been written to the response, we can now exit the handler\n    return\n  }\n  \n  result, err := DoWork(request)\n  \n  if httpu.Write500IfErr(err, w, \"Could not process request for: %v\", request.Value) {\n    // http.StatusInternalServerError has been written to the response\n    return\n  }\n  \n  httpu.EncodeJsonOr400(w, result, \"Could not encode response json for: %v\", result.Value)\n}\n```\nA full example is available [here](https://godoc.org/github.com/clavoie/httpu#example-WriteIfErr)\n\n## Dependency Injection\n\nhttpu provides an interface that wraps all top level functions if you would prefer to inject the package into your project. A full example of using httpu with dependency injection is [here](https://godoc.org/github.com/clavoie/httpu#example-Impl)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclavoie%2Fhttpu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclavoie%2Fhttpu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclavoie%2Fhttpu/lists"}