{"id":37158285,"url":"https://github.com/libsgh/nic","last_synced_at":"2026-01-14T18:53:48.385Z","repository":{"id":57597405,"uuid":"377538719","full_name":"libsgh/nic","owner":"libsgh","description":"🌀 Nic is a HTTP request client with elegant and easy-to-use API","archived":false,"fork":true,"pushed_at":"2021-07-05T13:24:44.000Z","size":1105,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-12-08T07:16:44.598Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"EddieIvan01/nic","license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/libsgh.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2021-06-16T15:13:14.000Z","updated_at":"2021-07-05T13:23:33.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/libsgh/nic","commit_stats":null,"previous_names":[],"tags_count":9,"template":null,"template_full_name":null,"purl":"pkg:github/libsgh/nic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libsgh%2Fnic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libsgh%2Fnic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libsgh%2Fnic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libsgh%2Fnic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/libsgh","download_url":"https://codeload.github.com/libsgh/nic/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libsgh%2Fnic/sbom","scorecard":{"id":588305,"data":{"date":"2025-08-11","repo":{"name":"github.com/libsgh/nic","commit":"5dbb94c38676b4afe1d4e79ba78a79e8edf0c1fc"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/26 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Mozilla Public License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T21:09:03.117Z","repository_id":57597405,"created_at":"2025-08-20T21:09:03.117Z","updated_at":"2025-08-20T21:09:03.117Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28430961,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T16:38:47.836Z","status":"ssl_error","status_checked_at":"2026-01-14T16:34:59.695Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":[],"created_at":"2026-01-14T18:53:47.754Z","updated_at":"2026-01-14T18:53:48.378Z","avatar_url":"https://github.com/libsgh.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nic\n\n![GitHub release](https://img.shields.io/github/release/eddieivan01/nic.svg?label=nic)  ![GitHub issues](https://img.shields.io/github/issues/eddieivan01/nic.svg)\n\nEnglish | [中文](https://github.com/EddieIvan01/nic/tree/master/docs/zh-cn.md)\n\nNic is a HTTP request client which has elegant, easy-to-use API\n\n***\n\n## Features\n\n+ wrapper of HTTP std lib, provids elegant and easy-to-use API\n\n+ keep session via `nic.Session` structure, `nic.Session` is go-routine safe\n\n***\n\n## Installation\n\nTo install nic, enter the following command\n\n```\n$ go get -v -u github.com/eddieivan01/nic\n```\n\n***\n\n## Quick start\n\nDo a HTTP request like this\n\n```go\nresp, err := nic.Get(\"http://example.com\", nil)\nif err != nil {\n    log.Fatal(err.Error())\n}\nfmt.Println(resp.Text)\n```\n\n***\n\n## Documentation\n\n## do a basic request\n\nnic could do these methods' request\n\n`\"HEAD\", \"GET\", \"POST\", \"DELETE\", \"OPTIONS\", \"PUT\", \"PATCH\"`\n\n```go\nimport (\n\t\"fmt\"\n    \"github.com/eddieivan01/nic\"\n)\n\nfunc main() {\n    url := \"http://example.com\"\n    resp, err := nic.Get(url, nil)\n    if err != nil {\n        log.Fatal(err.Error())\n    }\n    fmt.Println(resp.Text)\n}\n```\n\n## post request with some form data\n\nas you see, all requests' parameters are passed by `nic.H`, and the inner is saved in `nic.KV`, it's actually `map[string]interface{}`\n\n```go\nresp, err := nic.Post(url, nic.H{\n    Data : nic.KV{\n        \"nic\" : \"nic\",\n    },\n    Headers : nic.KV{\n        \"X-Forwarded-For\" : \"127.0.0.1\",\n    },\n})\n```\n\n## request with cookies\n\nof course, you can also set it in Headers\n\n```go\nresp, err := nic.Get(url, nic.H{\n    Cookies : nic.KV{\n        \"cookie\" : \"nic\",\n    },\n})\n```\n\n## request with files\n\nyou can upload files with files' name + files' content which is `[]byte` type, and can also upload via local file path\n\nwhile uploading a file, you can set `multipart` form's field name, filename and MIME type\n\nfor more convenient  setting files parameters, you can invoke in a chain to set `filename` and MIME type\n\n```go\nresp, err := nic.Post(url, nic.H{\n    Files : nic.KV{\n        \"file1\": nic.File(\n                    \"nic.go\", \n                    []byte(\"package nic\")),\n        \"file2\": nic.FileFromPath(\"./nic.go\").\n                    MIME(\"text/plain\").\n                    FName(\"nic\"),\n    },\n})\n```\n\n## request with JSON\n\n```go\nresp, err := nic.Post(url, nic.H{\n    JSON : nic.KV{\n        \"nic\" : \"nic\",\n    }\n})\n```\n\n## request with unencoded raw message\n\n```go\nresp, err := nic.Post(url, nic.H{\n    Raw : \"post body which is unencoded\",\n})\n```\n\n## using chunked transfer\n\nThe default is not to use chunked transfer\n\nenable the `transfer-encoding: chunked`\n\n```go\nresp, _ := nic.Get(url, nic.H{\n    Chunked: true,\n})\n```\n\n## set query params\n\n```go\nresp, err := nic.Get(url, nic.H {\n    Params: nic.KV {\n        \"a\": \"1\",\n    },\n})\n```\n\n## all the parameters you could set\n\n```go\nH struct {\n    Params  KV\n    Data    KV\n    Raw     string\n    Headers KV\n    Cookies KV\n    Auth    KV\n    Proxy   string\n    JSON    KV\n    Files   KV\n\n    AllowRedirect      bool\n    Timeout            int64\n    Chunked            bool\n    DisableKeepAlives  bool\n    DisableCompression bool\n    SkipVerifyTLS      bool\n}\n```\n\n## NOTICE\n\n`nic.H` can only have one of the following four parameters\n\n`H.Raw, H.Data, H.Files, H.JSON`\n\n## request with session, which could handle server's `set-cookie` header\n\n```go\nsession := nic.NewSession()\nresp, err := session.Post(\"http://example.com/login\", nic.H{\n    Data : nic.KV{\n        \"uname\" : \"nic\",\n        \"passwd\" : \"nic\",\n    },\n})\n\n// ......\n\nresp, err = session.Get(\"http://example.com/userinfo\", nil)\n```\n\n## handle response\n\n```go\nresp, _ := nic.Get(url, nil)\nfmt.Println(resp.Text)\nfmt.Println(resp.Bytes)\n```\n\n## handle JSON response\n\n```go\nresp, _ := nic.Get(url, nil)\n\ntype S struct {\n    P1 string `json:\"p1\"`\n    P2 string `json:\"p2\"`\n}\n\ns := \u0026S{}\nerr := resp.JSON(\u0026s)\n\nif err == nil {\n    fmt.Println(s.P1, s.P2)\n}\n```\n\n## change response's encoding\n\n`SetEncode` will convert `resp.Bytes` to `resp.Text` if encoding is changed every time be called \n\n```go\nresp, _ := nic.Get(url, nil)\nerr := resp.SetEncode(\"gbk\")\n\nif err == nil {\n    fmt.Println(resp.Text)\n}\n```\n\n## save response's content as a file\n\n```go\nresp, _ := nic.Get(\"http://example.com/1.jpg\", nil)\nerr := resp.SaveFile(\"1.jpg\")\n```\n\n***\n\n## register a request/response hook\n\n```go\nsession := nic.NewSession()\nsession.RegisterBeforeReqHook(func(r *http.Request) error {\n    r.URL.RawQuery = \"nic=nic\"\n    return nil\n})\nsession.RegisterAfterRespHook(func(r *http.Response) error {\n    r.Header.Set(\"nic\", \"nic\")\n    return nil\n})\n\nsession.Get(url, nil)\n```\n\n***\n\n## QA\n\n+ Q:\n\n  How to get origin `*http.Request` from `nic.Session`?\n\n  A:\n\n  by `nic.Session.GetRequest` method\n\n+ Q:\n\n  How to pass origin `*http.Response` to goquery-like DOM-parsing-libs from `nic.Response`?\n\n  A:\n\n  use `resp, _ := nic.Get(...); resp.Response` to access origin anonymous structure `*http.Response`; and `(*http.Response).Body's IO.Reader` has been saved, you can  use `*http.Response` as if it were the original structure\n\n+ Q:\n\n  Redirection is allowed 10 times by default, how could I increase the number?\n\n  A:\n\n  by access `nic.Session.Client` then change its CheckRedirect property\n\n+ Q:\n\n  How to use the chunked transfer-encoding?\n\n  A:\n\n  by nic.H{Chunked: true}","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibsgh%2Fnic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibsgh%2Fnic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibsgh%2Fnic/lists"}