{"id":37173873,"url":"https://github.com/goioc/web","last_synced_at":"2026-01-14T20:19:15.943Z","repository":{"id":38319971,"uuid":"274243026","full_name":"goioc/web","owner":"goioc","description":"Web Framework for Go, based on goioc/di","archived":false,"fork":false,"pushed_at":"2024-11-25T09:12:48.000Z","size":77,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-25T10:29:11.657Z","etag":null,"topics":["go","golang","golang-library","rest-api","web","web-framework"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/goioc/web/?tab=doc","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/goioc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"ko_fi":"dtitov"}},"created_at":"2020-06-22T21:10:29.000Z","updated_at":"2024-11-25T09:12:45.000Z","dependencies_parsed_at":"2023-11-06T09:48:17.435Z","dependency_job_id":"624cf9a5-7d45-4e00-93eb-822d4e7c13e1","html_url":"https://github.com/goioc/web","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/goioc/web","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goioc%2Fweb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goioc%2Fweb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goioc%2Fweb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goioc%2Fweb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goioc","download_url":"https://codeload.github.com/goioc/web/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goioc%2Fweb/sbom","scorecard":{"id":434104,"data":{"date":"2025-08-11","repo":{"name":"github.com/goioc/web","commit":"ea1e909f57648f925559c1e728ae3b3a18bd4011"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.4,"checks":[{"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":"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":"Pinned-Dependencies","score":2,"reason":"dependency not pinned by hash detected -- score normalized to 2","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/goioc/web/codeql.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/goioc/web/codeql.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/goioc/web/codeql.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/goioc/web/codeql.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/dependency-review.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/goioc/web/dependency-review.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/dependency-review.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/goioc/web/dependency-review.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/goioc/web/go.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/goioc/web/go.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/go.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/goioc/web/go.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/greetings.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/goioc/web/greetings.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/stale.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/goioc/web/stale.yml/master?enable=pin","Info:   0 out of  10 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   1 out of   1 goCommand dependencies pinned"],"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":"Code-Review","score":0,"reason":"Found 0/20 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":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql.yml:16","Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql.yml:17","Warn: no topLevel permission defined: .github/workflows/codeql.yml:1","Info: topLevel 'contents' permission set to 'read': .github/workflows/dependency-review.yml:11","Warn: no topLevel permission defined: .github/workflows/go.yml:1","Warn: no topLevel permission defined: .github/workflows/greetings.yml:1","Warn: no topLevel permission defined: .github/workflows/stale.yml:1","Info: no jobLevel write permissions found"],"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: MIT License: 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":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"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"}},{"name":"SAST","score":7,"reason":"SAST tool detected but not run on all commits","details":["Info: SAST configuration detected: CodeQL","Warn: 1 commits out of 10 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T04:10:10.003Z","repository_id":38319971,"created_at":"2025-08-19T04:10:10.003Z","updated_at":"2025-08-19T04:10:10.003Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28434422,"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":["go","golang","golang-library","rest-api","web","web-framework"],"created_at":"2026-01-14T20:19:15.156Z","updated_at":"2026-01-14T20:19:15.935Z","avatar_url":"https://github.com/goioc.png","language":"Go","readme":"# goioc/web: Web Framework for Go, based on goioc/di\n[![goioc](https://habrastorage.org/webt/ym/pu/dc/ympudccm7j7a3qex_jjroxgsiwg.png)](https://github.com/goioc)\n\n![Go](https://github.com/goioc/web/workflows/Go/badge.svg)\n[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go\u0026logoColor=white\u0026style=flat-square)](https://pkg.go.dev/github.com/goioc/web/?tab=doc)\n[![CodeFactor](https://www.codefactor.io/repository/github/goioc/web/badge)](https://www.codefactor.io/repository/github/goioc/web)\n[![Go Report Card](https://goreportcard.com/badge/github.com/goioc/WEB)](https://goreportcard.com/report/github.com/goioc/web)\n[![codecov](https://codecov.io/gh/goioc/web/branch/master/graph/badge.svg)](https://codecov.io/gh/goioc/web)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=goioc_web\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=goioc_web)\n[![DeepSource](https://static.deepsource.io/deepsource-badge-light-mini.svg)](https://deepsource.io/gh/goioc/web/?ref=repository-badge)\n\n## How is this framework different from others?\n\n1. First of all, `goioc/web` is working using Dependency Injection and is based on [goioc/di](https://github.com/goioc/di), which is the IoC Container.\n2. Secondly - and this is the most exciting part - web-endpoints in `goioc/web` can have (almost) arbitrary signature! \nNo more `func(w http.ResponseWriter, r *http.Request)` handlers, if your endpoint receives a `string` and produces a binary stream, just declare it as is:\n\n```go\n...\nfunc (e *endpoint) Hello(name string) io.Reader {\n\treturn bytes.NewBufferString(\"Hello, \" + name + \"!\")\n}\n...\n```\n\nCool, huh? 🤠 Of course, you can still directly use `http.ResponseWriter` and `*http.Request`, if you like.\n\n## Basic concepts\n\nThe main entity in `goioc/web` is the Endpoint, which is represented by the interface of the same name. Here's the example implementation:\n\n```go\ntype endpoint struct {\n}\n\nfunc (e endpoint) HandlerFuncName() string {\n\treturn \"Hello\"\n}\n\nfunc (e *endpoint) Hello(name string) io.Reader {\n\treturn bytes.NewBufferString(\"Hello, \" + name + \"!\")\n}\n```\n\n`Endpoint` interface has one method that returns the name of the method that will be used as an endpoint.\n\nIn order for `goioc/web` to pick up this endpoint, it should be registered in the DI Container:\n\n```go\n_, _ = di.RegisterBean(\"endpoint\", reflect.TypeOf((*endpoint)(nil)))\n```\n\nThen the container should be initialized (please, refer to the [goioc/di](https://github.com/goioc/di) documentation for more details):\n\n```go\n_ = di.InitializeContainer()\n```\n\nFinally, the web-server can be started, either using the built-in function:\n\n```go\n_ = web.ListenAndServe(\":8080\")\n```\n... or using returned `Router`\n```go\nrouter, _ := web.CreateRouter()\n_ = http.ListenAndServe(\":8080\", router)\n```\n\n## Routing\n\nSo, how does the framework know where to bind this endpoint to? \nFor the routing functionality `goioc/web` leverages [gorilla/mux](https://github.com/gorilla/mux) library.\nDon't worry: you don't have to cope with this library directly: `goioc/web` provides a set of convenient wrappers around it.\nThe wrappers are implemented as tags in the endpoint-structure. Let's slightly update our previous example:\n\n```go\n...\ntype endpoint struct {\n\tmethod interface{} `web.methods:\"GET\"`\n\tpath   interface{} `web.path:\"/hello\"`\n}\n...\n```\n\nNow our endpoint is bound to a `GET` requests at the `/hello` path. Yes, it's that simple! 🙂\n\n### `goioc/web` tags\n\n| **Tag**       | **Value**                                 | **Example**                                           |\n|---------------|-------------------------------------------|-------------------------------------------------------|\n| `web.methods` | List of HTTP-methods.                     | `web.methods:\"POST,PATCH\"`                            |\n| `web.path`    | URL sub-path. Can contain path variables. | `web.path:\"/articles/{category}/{id:[0-9]+}\"`         |\n| `web.queries` | Key-value paris of the URL query part.    | `web.queries:\"foo,bar,id,{id:[0-9]+}\"`                |\n| `web.headers` | Key-value paris of the request headers.   | `web.headers:\"Content-Type,application/octet-stream\"` |\n| `web.matcher` | ID of the bean of type `*mux.MatcherFunc`.| `web.matcher:\"matcher\"`                               |\n\n## In and Out types\n\nAs was mentioned above, with `goioc/web` you get a lot of freedom in terms of defining the signature of your endpoint's method. \nJust look at these examples:\n\n```go\n...\nfunc (e *endpoint) Error() (int, string) {\n\treturn 505, \"Something bad happened :(\"\n}\n...\n```\n\n```go\n...\nfunc (e *endpoint) KeyValue(ctx context.Context) string {\n\treturn ctx.Value(di.BeanKey(\"key\")).(string)\n}\n...\n```\n\n```go\n...\nfunc (e *endpoint) Hello(pathParams map[string]string) (http.Header, int) {\n\treturn map[string][]string{\n    \t\t\"Content-Type\": {\"application/octet-stream\"},\n    \t}, []byte(\"Hello, \" + pathParams[\"name\"] + \"!\")\n}\n...\n```\n\n### Supported argument types\n\n- `http.ResponseWriter`\n- `*http.Request`\n- `context.Context`\n- `http.Header`\n- `io.Reader`\n- `io.ReadCloser`\n- `[]byte`\n- `string`\n- `map[string]string`\n- `url.Values`\n- `struct` implementing `encoding.BinaryUnmarshaler` or `encoding.TextUnmarshaler`\n- `interface{}` (`GoiocSerializer` bean is used to deserialize such arguments)\n\n### Supported return types\n\n- `http.Header` (response headers, must be first return argument, if used)\n- `int` (status code, must be first argument after response headers, if used)\n- `io.Reader`\n- `io.ReadCloser`\n- `[]byte`\n- `string`\n- `struct` implementing `encoding.BinaryMarshaler` or `encoding.TextMarshaler`\n- `interface{}` (`GoiocSerializer` bean is used to serialize such returned object)\n\n### Templates\n\n`goioc/web` supports templates!\n\n**todo.html**\n```html\n\u003ch1\u003e{{.PageTitle}}\u003c/h1\u003e\n\u003cul\u003e\n    {{range .Todos}}\n        {{if .Done}}\n            \u003cli class=\"done\"\u003e{{.Title}}\u003c/li\u003e\n        {{else}}\n            \u003cli\u003e{{.Title}}\u003c/li\u003e\n        {{end}}\n    {{end}}\n\u003c/ul\u003e\n```\n\n**endpoint.go**\n```go\ntype todo struct {\n\tTitle string\n\tDone  bool\n}\ntype todoPageData struct {\n\tPageTitle string\n\tTodos     []todo\n}\n\ntype todoEndpoint struct {\n\tmethod interface{} `web.methods:\"GET\"`\n\tpath   interface{} `web.path:\"/todo\"`\n}\n\nfunc (e todoEndpoint) HandlerFuncName() string {\n\treturn \"TodoList\"\n}\n\nfunc (e *todoEndpoint) TodoList() (template.Template, interface{}) {\n\ttmpl := template.Must(template.ParseFiles(\"todo.html\"))\n\treturn *tmpl, todoPageData{\n\t\tPageTitle: \"My TODO list\",\n\t\tTodos: []todo{\n\t\t\t{Title: \"Task 1\", Done: false},\n\t\t\t{Title: \"Task 2\", Done: true},\n\t\t\t{Title: \"Task 3\", Done: true},\n\t\t},\n\t}\n}\n```\n\n**Note** that in case of using templates, the next returned object after `template.Template` must be the actual structure that will be used to fill in the template 💡\n\n## Custom matchers\n\nIf functionality of `web.methods`, `web.path`, `web.queries` and `web.headers` is not enough for you, you can use custom matcher, \nbased on Gorilla's `mux.MatcherFunc`:\n\n```go\n...\n_, _ = di.RegisterBeanFactory(\"matcher\", di.Singleton, func(context.Context) (interface{}, error) {\n\t\tmatcherFunc := mux.MatcherFunc(func(request *http.Request, match *mux.RouteMatch) bool {\n\t\t\treturn strings.HasSuffix(request.URL.Path, \"bar\")\n\t\t})\n\t\treturn \u0026matcherFunc, nil\n\t})\n\n...\n\ntype endpoint struct {\n\tmethod  interface{} `web.methods:\"GET\"`\n\tpath    interface{} `web.path:\"/endpoint/{key}/{*?}\"`\n\tmatcher interface{} `web.matcher:\"matcher\"`\n}\n\nfunc (e endpoint) HandlerFuncName() string {\n\treturn \"Match\"\n}\n\nfunc (e *endpoint) Match() string {\n\treturn \"It's a match! :)\"\n}\n...\n```\n```bash\n$ curl localhost:8080/endpoint/foo/bar\nIt's a match! :)                \n```\n\n## Middleware\n\nOf course, custom middleware is also supported by the framework:\n\n```go\nweb.Use(func(next http.Handler) http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tnext.ServeHTTP(w, r.WithContext(context.WithValue(r.Context(), di.BeanKey(\"key\"), \"value\")))\n\t})\n})\n```\n\n","funding_links":["https://ko-fi.com/dtitov"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoioc%2Fweb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoioc%2Fweb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoioc%2Fweb/lists"}