{"id":25170193,"url":"https://github.com/gosuit/httper","last_synced_at":"2025-04-03T20:25:16.192Z","repository":{"id":274943769,"uuid":"924556471","full_name":"gosuit/httper","owner":"gosuit","description":"Library for working with HTTP","archived":false,"fork":false,"pushed_at":"2025-03-30T10:18:08.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-30T11:19:22.545Z","etag":null,"topics":["client","golang","http","server"],"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/gosuit.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":"2025-01-30T08:27:09.000Z","updated_at":"2025-03-30T10:04:38.000Z","dependencies_parsed_at":"2025-03-30T11:19:13.470Z","dependency_job_id":"7a6b9b6c-ac86-4443-93e6-0aaf577e864e","html_url":"https://github.com/gosuit/httper","commit_stats":null,"previous_names":["gosuit/httper"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gosuit%2Fhttper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gosuit%2Fhttper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gosuit%2Fhttper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gosuit%2Fhttper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gosuit","download_url":"https://codeload.github.com/gosuit/httper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247072407,"owners_count":20878884,"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":["client","golang","http","server"],"created_at":"2025-02-09T08:39:10.765Z","updated_at":"2025-04-03T20:25:16.185Z","avatar_url":"https://github.com/gosuit.png","language":"Go","readme":"# Httper\n\nThis is a simple and flexible HTTP library for Go that provides an easy way to create HTTP servers and clients. The library allows you to configure server settings, manage requests, and handle responses with support for marshaling and unmarshaling of request and response bodies.\n\n## Installation\n\n```zsh\ngo get github.com/gosuit/httper\n```\n\n## Features\n\n- Create and configure HTTP servers with customizable timeouts.\n- Build HTTP clients with URL prefixes and timeout settings.\n- Easy-to-use API for making HTTP requests.\n- Support for marshaling and unmarshaling request and response bodies in JSON, XML and other formats.\n\n## Usage\n\n### Server\n\n```golang\npackage main\n\nimport (\n    \"time\"\n    \"log/slog\"\n\n    \"github.com/gosuit/httper\"\n)\n\n\nfunc main() {\n    log := slog.Default()\n\n    cfg := httper.ServerCfg{\n        Url:             \":8080\",\n        ReadTimeout:     5 * time.Second,\n        WriteTimeout:    10 * time.Second,\n        ShutdownTimeout: 5 * time.Second,\n    }\n\n    handler := http.HandlerFunc(yourHandlerFunction) // Your custom handler function\n    server := httper.NewServer(cfg, handler)\n\n    server.Start()\n\n\terr := server.Shutdown(log)\n    // Handling error\n}\n```\n\n### Client\n\n```golang\npackage main\n\nimport (\n    \"time\"\n    \"log/slog\"\n\n    \"github.com/gosuit/httper\"\n)\n\ntype Result struct {\n    Field1 string `json:\"field\"`\n}\n\nfunc main() {\n    log := slog.Default()\n\n    clientCfg := httper.ClientCfg{\n        Prefix:  \"http://api.example.com\",\n        Timeout: 5 * time.Second,\n    }\n\n    client := httper.NewClient(clientCfg)  \n    \n    var result Result\n\n    req, err := httper.NewReq(\u0026httper.Params{\n        Method:        httper.GetMethod,\n        Url:           \"/endpoint\",\n        Unmarshal:     true,\n        UnmarshalTo:   \u0026result,\n        UnmarshalType: httper.JsonType,\n    })\n    if err != nil {\n        log.Fatal(err)\n    }\n\n    resp, err := client.Do(req)\n    if err != nil {\n        log.Fatal(err)\n    }\n\n    // Handle response\n    fmt.Println(result)\n}\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a pull request or open an issue for any enhancements or bug fixes.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgosuit%2Fhttper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgosuit%2Fhttper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgosuit%2Fhttper/lists"}