{"id":34839017,"url":"https://github.com/infiniteloopcloud/hyper","last_synced_at":"2026-05-23T01:02:07.766Z","repository":{"id":43272093,"uuid":"444410316","full_name":"infiniteloopcloud/hyper","owner":"infiniteloopcloud","description":"General HTTP helper library aims to be customizable.","archived":false,"fork":false,"pushed_at":"2024-08-12T13:18:50.000Z","size":109,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-08-12T14:55:10.609Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/infiniteloopcloud.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":"2022-01-04T12:27:03.000Z","updated_at":"2024-08-12T13:14:31.000Z","dependencies_parsed_at":"2024-08-12T15:08:58.793Z","dependency_job_id":null,"html_url":"https://github.com/infiniteloopcloud/hyper","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/infiniteloopcloud/hyper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infiniteloopcloud%2Fhyper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infiniteloopcloud%2Fhyper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infiniteloopcloud%2Fhyper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infiniteloopcloud%2Fhyper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/infiniteloopcloud","download_url":"https://codeload.github.com/infiniteloopcloud/hyper/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infiniteloopcloud%2Fhyper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33378554,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-22T21:56:13.512Z","status":"ssl_error","status_checked_at":"2026-05-22T21:56:10.769Z","response_time":265,"last_error":"SSL_read: 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":[],"created_at":"2025-12-25T16:58:32.816Z","updated_at":"2026-05-23T01:02:07.754Z","avatar_url":"https://github.com/infiniteloopcloud.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hyper\n\nGeneral HTTP helper library aims to be customizable.\n\n- [Non-TLS](#non-tls)\n- [TLS](#tls)\n- [Bind request body](#bind-request-body)\n- [Error handling](#error-handling)\n- [Client](#client)\n\n### Usage\n\n#### Non-TLS\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/infiniteloopcloud/hyper\"\n\t\"github.com/infiniteloopcloud/log\"\n)\n\nfunc main() {\n\tvar h = hyper.HTTP{\n\t\tPreHooks: []func(ctx context.Context){\n\t\t\tpreHookSetLogLevel,\n\t\t},\n\t\tLog: hyper.Logger{\n\t\t\tInfof:  log.Infof,\n\t\t\tErrorf: log.Errorf,\n\t\t},\n\t\tAddress: os.Getenv(\"SERVICE_HTTP_ADDRESS\"),\n\t\tHandler: chi.NewRouter(),\n\t}\n\t\n\th.Run()\n}\n\nfunc preHookSetLogLevel(_ context.Context) {\n\tlog.SetLevel(func() uint8 {\n\t\treturn 1\n\t}())\n}\n```\n\n#### TLS\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/infiniteloopcloud/hyper\"\n\t\"github.com/infiniteloopcloud/log\"\n)\n\nfunc main() {\n\tvar h = hyper.HTTP{\n\t\tPreHooks: []func(ctx context.Context){\n\t\t\tpreHookSetLogLevel,\n\t\t},\n\t\tLog: hyper.Logger{\n\t\t\tInfof:  log.Infof,\n\t\t\tErrorf: log.Errorf,\n\t\t},\n\t\tAddress: os.Getenv(\"SERVICE_HTTP_ADDRESS\"),\n\t\tHandler: chi.NewRouter(),\n\t}\n\n\t// NewEnvironmentTLS able to build PEM block based on the provided information\n\tif os.Getenv(\"SERVICE_TLS_SUPPORT\") == \"PEM_BUILDER\" {\n\t\th.TLSEnabled = true\n\t\th.TLS = hyper.NewEnvironmentTLS(hyper.EnvironmentTLSOpts{\n\t\t\tTLSCert:          \"SERVICE_TLS_CERT\",\n\t\t\tTLSCertBlockType: \"SERVICE_TLS_CERT_BLOCK_NAME\",\n\t\t\tTLSKey:           \"SERVICE_TLS_KEY\",\n\t\t\tTLSKeyBlockType:  \"SERVICE_TLS_KEY_BLOCK_NAME\",\n\t\t})\n    // NewFileTLS reads the files from the provided location\n\t} else if os.Getenv(\"SERVICE_TLS_SUPPORT\") == \"FILE\" {\n\t\th.TLSEnabled = true\n\t\th.TLS = hyper.NewFileTLS(hyper.FileTLSOpts{\n\t\t\tTLSCertPath: \"SERVICE_TLS_CERT\",\n\t\t\tTLSKeyPath:  \"SERVICE_TLS_KEY\",\n\t\t})\n\t}\n\t\n\th.Run()\n}\n\nfunc preHookSetLogLevel(_ context.Context) {\n\tlog.SetLevel(func() uint8 {\n\t\treturn 1\n\t}())\n}\n```\n\n#### Bind request body\n\n```go\npackage main\n\nimport (\n\t\"net/http\"\n\n\t\"github.com/infiniteloopcloud/hyper\"\n)\n\ntype Request struct {\n\tField1 string `json:\"field1\"`\n}\n\nfunc main() {}\n\nfunc handler(w http.ResponseWriter, r *http.Request) {\n\tctx := r.Context()\n\n\tvar reqStruct Request\n\t// Bind the JSON request\n\tif err := hyper.Bind(ctx, r, \u0026reqStruct); err != nil {\n\t\thyper.ReturnBadRequest(ctx, w, \"invalid request body\", err)\n\t\treturn\n\t}\n\n\tw.WriteHeader(http.StatusOK)\n}\n```\n\n#### Error handling\n\nThere are pure error wrappers which wraps the error into a weird.Error:\n\n- `BadRequest(...)`\n- `NotFound(...)`\n- `Unauthorized(...)`\n- `Forbidden(...)`\n- `InternalServerError(...)`\n\nAll of these has a Return{...} function if the function has access to `http.ResponseWriter`\n\n- `ReturnBadRequest(...)`\n- `ReturnNotFound(...)`\n- `ReturnUnauthorized(...)`\n- `ReturnForbidden(...)`\n- `ReturnInternalServerError(...)`\n\n```go\npackage main\n\nimport (\n\t\"net/http\"\n\n\t\"github.com/infiniteloopcloud/hyper\"\n)\n\ntype Request struct {\n\tField1 string `json:\"field1\"`\n}\n\nfunc main() {}\n\nfunc handler(w http.ResponseWriter, r *http.Request) {\n\tctx := r.Context()\n\n\tvar reqStruct Request\n\tif err := hyper.Bind(ctx, r, \u0026reqStruct); err != nil {\n\t\t// Return bad request will write the response into w\n\t\thyper.ReturnBadRequest(ctx, w, \"invalid request body\", err)\n\t\treturn\n\t}\n\n\tw.WriteHeader(http.StatusOK)\n}\n```\n\n#### Client\n\nHTTP client-side helper functions.\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\n\t\"github.com/infiniteloopcloud/hyper\"\n)\n\ntype Response struct {\n\tField1 string `json:\"f\"`\n}\n\nfunc main() {\n\tctx := context.Background()\n\tvar resp Response\n\thyper.Request(ctx, \u0026resp, hyper.RequestOpts{\n\t\tMethod:         \"POST\",\n\t\tEndpoint:       \"/api/endpoint\",\n\t\t// RequestStruct:  req,\n\t\tClient:         hyper.Client(),\n\t})\n\t// handle err\n\t// use resp\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfiniteloopcloud%2Fhyper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finfiniteloopcloud%2Fhyper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfiniteloopcloud%2Fhyper/lists"}