{"id":15097806,"url":"https://github.com/ryouaki/koa","last_synced_at":"2026-01-11T23:03:09.600Z","repository":{"id":41396632,"uuid":"320140996","full_name":"ryouaki/koa","owner":"ryouaki","description":"A golang framework like koa.js and has the best performance with net/http.","archived":false,"fork":false,"pushed_at":"2023-10-19T11:26:43.000Z","size":299,"stargazers_count":40,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-14T22:35:49.527Z","etag":null,"topics":["go","golang","koa","koajs","middleware","web-framework"],"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/ryouaki.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":"2020-12-10T02:50:18.000Z","updated_at":"2024-03-16T05:42:32.000Z","dependencies_parsed_at":"2024-06-19T09:59:48.191Z","dependency_job_id":null,"html_url":"https://github.com/ryouaki/koa","commit_stats":null,"previous_names":["ryouaki/koa.go"],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/ryouaki/koa","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryouaki%2Fkoa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryouaki%2Fkoa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryouaki%2Fkoa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryouaki%2Fkoa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryouaki","download_url":"https://codeload.github.com/ryouaki/koa/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryouaki%2Fkoa/sbom","scorecard":{"id":793131,"data":{"date":"2025-08-11","repo":{"name":"github.com/ryouaki/koa","commit":"a6ad11c4b75351dab64a5ee7a3ea5b88b1dc717e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"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":"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":"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":"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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/go.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":"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":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/ryouaki/koa/go.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/ryouaki/koa/go.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/go.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/ryouaki/koa/go.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/go.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/ryouaki/koa/go.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/go.yml:52: update your workflow using https://app.stepsecurity.io/secureworkflow/ryouaki/koa/go.yml/main?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   3 third-party GitHubAction 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":"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":"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":"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":"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 'main'","Warn: branch protection not enabled for branch 'v1.3.9'","Warn: branch protection not enabled for branch 'v1.3.7'"],"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 18 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"}},{"name":"Vulnerabilities","score":8,"reason":"2 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2021-0061 / GHSA-r88r-gmrh-7j83","Warn: Project is vulnerable to: GO-2020-0036 / GHSA-wxc4-f4m6-wwqv"],"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-23T08:08:41.615Z","repository_id":41396632,"created_at":"2025-08-23T08:08:41.615Z","updated_at":"2025-08-23T08:08:41.615Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28326166,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T22:11:01.104Z","status":"ssl_error","status_checked_at":"2026-01-11T22:10:58.990Z","response_time":60,"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":["go","golang","koa","koajs","middleware","web-framework"],"created_at":"2024-09-25T16:40:32.621Z","updated_at":"2026-01-11T23:03:09.579Z","avatar_url":"https://github.com/ryouaki.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"![](https://www.oscs1024.com/platform/badge/ryouaki/koa.svg)\n![Coverage](https://img.shields.io/badge/Coverage-8.9%25-red)\n![](https://goreportcard.com/badge/github.com/ryouaki/koa)\n[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)\n\n# koa.go\nExpressive HTTP middleware framework for Golang to make web applications and APIs more enjoyable to write like Koa.js. Koa's middleware stack flows in a stack-like manner, allowing you to perform actions downstream then filter and manipulate the response upstream.\n\nKoa is not bundled with any middleware.\n\n## Benchmarks\nryouaki/koa has the best performance:\n\n| name | qps | transactions/s |\n|--|--|--|\n|koa(golang) | 12598080 | 42014.05 |\n|gin | 11936723 | 39812.96 |\n|echo | 12347680 | 41179.66\t |\n|beego | 11051408 | 36856.09 |\n|koa(nodejs) | 8042021 | 26818.72\t |\n\n## Installation\n```go\n  $ go get github.com/ryouaki/koa\n```\n\n## Hello Koa\n```go\n  package main\n\n  import (\n    \"fmt\"\n\n    \"github.com/ryouaki/koa\"\n  )\n\n  func main() {\n    app := koa.New() // 初始化服务对象\n\n    // 设置api路由，其中var为url传参\n    app.Get(\"/\", func(ctx *koa.Context, next koa.Next) {\n      ctx.SetBody([]byte(\"Hello Koa\"))\n    })\n\n    err := app.Run(8080) // 启动\n    if err != nil {      // 是否发生错误\n      fmt.Println(err)\n    }\n  }\n```\n\n## Middleware\nKoa is a middleware framework, Here is an example of logger middleware with each of the different functions:\n\n```go\n  package plugin\n\n  import (\n    \"fmt\"\n    \"time\"\n\n    \"github.com/ryouaki/koa\"\n  )\n\n  // Log out about the duration for request.\n  func Duration(ctx *koa.Context, next koa.Next) {\n    startTime := time.Now() // 开始计时\n    next(nil) // 执行后续操作\n    d := time.Now().Sub(startTime) // 计算耗时\n    // 打印结果\n    fmt.Println(time.Date(startTime.Year(),\n      startTime.Month(),\n      startTime.Day(),\n      startTime.Hour(),\n      startTime.Minute(),\n      startTime.Second(), 0, time.Local),\n      ctx.URL,\n      \"Request cost: \",\n      float64(d)/float64(time.Millisecond), \"ms\")\n  }\n```\n\n\n\n\n## Koa Application\n```go\n  type Application struct {\n    handles []Handle\n    _cb     Handler\n  }\n\n  type Handle struct {\n    path     string\n    method  string\n    handler Handler\n  }\n\n  // Handler Func\n  type Handler func(ctx *Context, n Next)\n\n  // Next Func\n  type Next func()\n\n  // New a Koa instance\n  func New() *Application\n  // Add a middleware for koa application\n  /**\n  * params: path\u003cstring|option\u003e path for request\n  * params: callback\u003ckoa.Handler|option\u003e cb for request\n  * params: callback ...\n  */\n  func (app *Application) Use(argus ...interface{})\n  // Get func\n  func (app *Application) Get(path string, cbFunc ...Handler) error\n  // Post func\n  func (app *Application) Post(path string, cbFunc ...Handler) error\n  // Delete func\n  func (app *Application) Delete(path string, cbFunc ...Handler) error\n  // Patch func\n  func (app *Application) Patch(path string, cbFunc ...Handler) error \n  // Put func\n  func (app *Application) Put(path string, cbFunc ...Handler) error\n  // Options func\n  func (app *Application) Options(path string, cbFunc ...Handler) error\n  // Head func\n  func (app *Application) Head(path string, cbFunc ...Handler) error\n  // Run func\n  func (app *Application) Run(port int) error \n  // RunTLS func\n  func (app *Application) RunTLS(port int, certFile string, keyFile string) error \n```\n\n## About Context\n```go\n  type Context struct {\n    Res      http.ResponseWriter    // Res the response object\n    Req      *http.Request          // Req the request object from client\n    Url      string                 // Url\n    Path     string                 // Rqeust path\n    Method   string                 // Method like Get, Post and others\n    Status   int                    // Status you want to let client konw for the request\n    MatchURL string                 // For the router path\n    Body     []uint8                // The body from client\n    Query    map[string]([]string)  // The Query from request's path\n    Params   map[string](string)    // The Params from request's path\n  }\n\n  // New a context for request\n  func NewContext(res http.ResponseWriter, req *http.Request) *Context\n  // Get Header from request func\n  func (ctx *Context) GetHeader(key string) []string \n  // Set header item for Response func\n  func (ctx *Context) SetHeader(key string, value string)\n  // Get cookie from request func\n  func (ctx *Context) GetCookie(key string) *http.Cookie\n  // Set cookie for response func\n  func (ctx *Context) SetCookie(cookie *http.Cookie)\n  // Set data for context func\n  func (ctx *Context) GetData(key string) interface{}\n  // Get data from contexxt  func\n  func (ctx *Context) SetData(key string, value interface{})\n  // Set data for response\n  func (ctx *Context) SetBody(data []byte)\n```\n\n## Components\n- [github.com/ryouaki/koa/log](https://github.com/ryouaki/koa/blob/main/log/log.md) Logger plugin\n- [github.com/ryouaki/koa/session](https://github.com/ryouaki/koa/blob/main/session/session.md) The middleware for session. support two way to save data - memory and redis base on go-redis\n- [github.com/ryouaki/koa/static](https://github.com/ryouaki/koa/blob/main/static/static.md) The middleware for Static.\n- [github.com/ryouaki/koa/env](https://github.com/ryouaki/koa/blob/main/static/env.md) The plugin for env configuration and extends base env.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryouaki%2Fkoa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryouaki%2Fkoa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryouaki%2Fkoa/lists"}