{"id":16307057,"url":"https://github.com/fujiwara/ridge","last_synced_at":"2025-10-05T01:32:22.239Z","repository":{"id":47781105,"uuid":"69677683","full_name":"fujiwara/ridge","owner":"fujiwara","description":"AWS Lambda HTTP Proxy integration event bridge to Go net/http.","archived":false,"fork":false,"pushed_at":"2025-07-26T06:34:31.000Z","size":159,"stargazers_count":64,"open_issues_count":6,"forks_count":8,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-26T12:20:33.054Z","etag":null,"topics":["apex","apigateway","aws","go","golang","lambda"],"latest_commit_sha":null,"homepage":null,"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/fujiwara.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["fujiwara"]}},"created_at":"2016-09-30T15:17:34.000Z","updated_at":"2025-04-29T07:32:28.000Z","dependencies_parsed_at":"2022-09-26T20:02:08.398Z","dependency_job_id":"f2b278cc-de0d-432b-bff6-0ca9a29103de","html_url":"https://github.com/fujiwara/ridge","commit_stats":{"total_commits":69,"total_committers":4,"mean_commits":17.25,"dds":"0.14492753623188404","last_synced_commit":"6ed926a2c0e7b5477e8c87b8881fcac5d059da1d"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/fujiwara/ridge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fujiwara%2Fridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fujiwara%2Fridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fujiwara%2Fridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fujiwara%2Fridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fujiwara","download_url":"https://codeload.github.com/fujiwara/ridge/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fujiwara%2Fridge/sbom","scorecard":{"id":413360,"data":{"date":"2025-08-11","repo":{"name":"github.com/fujiwara/ridge","commit":"574523a4f40815ec7660bdd35c3885f7482920a9"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.6,"checks":[{"name":"Code-Review","score":2,"reason":"Found 1/4 approved changesets -- score normalized to 2","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":10,"reason":"26 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10","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":"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:14: update your workflow using https://app.stepsecurity.io/secureworkflow/fujiwara/ridge/go.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/fujiwara/ridge/go.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tagpr.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/fujiwara/ridge/tagpr.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/tagpr.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/fujiwara/ridge/tagpr.yml/main?enable=pin","Info:   0 out of   3 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 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":"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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/go.yml:1","Warn: topLevel 'contents' permission set to 'write': .github/workflows/tagpr.yml:8","Warn: topLevel 'actions' permission set to 'write': .github/workflows/tagpr.yml:10","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":"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":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"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":"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":"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":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 29 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-18T23:14:08.838Z","repository_id":47781105,"created_at":"2025-08-18T23:14:08.839Z","updated_at":"2025-08-18T23:14:08.839Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278399628,"owners_count":25980330,"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","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["apex","apigateway","aws","go","golang","lambda"],"created_at":"2024-10-10T21:12:22.650Z","updated_at":"2025-10-05T01:32:22.232Z","avatar_url":"https://github.com/fujiwara.png","language":"Go","funding_links":["https://github.com/sponsors/fujiwara"],"categories":[],"sub_categories":[],"readme":"# ridge\n\nAWS Lambda HTTP Proxy integration event bridge to Go's net/http.\n\n## Example\n\nridge is a bridge to convert request/response payload of API Gateway / ALB / Function URLs to Go's net/http.Request and net/http.ResponseWriter.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\n\t\"github.com/fujiwara/ridge\"\n)\n\nfunc main() {\n\tvar mux = http.NewServeMux()\n\tmux.HandleFunc(\"/\", handleRoot)\n\tmux.HandleFunc(\"/hello\", handleHello)\n\tridge.Run(\":8080\", \"/\", mux)\n}\n\nfunc handleHello(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"text/plain\")\n\tfmt.Fprintf(w, \"Hello %s\\n\", r.FormValue(\"name\"))\n}\n\nfunc handleRoot(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"text/plain\")\n\tfmt.Fprintln(w, \"Hello World\")\n\tfmt.Fprintln(w, r.URL)\n}\n```\n\nThis code works on AWS Lambda and also as a standalone HTTP server.\n\nIf you run this code on AWS Lambda, you can access the function via API Gateway,  ALB,  or Function URLs. ridge converts the request payload to Go's net/http.Request, and the response that your app returns converts to the payload of Lambda.\n\nYou can access the function via Go's net/http server if you run this code as a standalone HTTP server.\n\nSo you can develop and test your Lambda function locally without deploying to AWS.\n\nAlso, you can switch the runtime environment between AWS Lambda and a standalone HTTP server on Amazon ECS, Amazon EC2, or AWS AppRunner **without any code and built binary changes**.\n\n### ridge.Run(address, prefix, handler)\n\n`ridge.Run(address, prefix, handler)` works as below.\n\n- If a process is running on Lambda (`AWS_EXECUTION_ENV` or `AWS_LAMBDA_RUNTIME_API` environment variable defined),\n  - Call lambda.Start()\n- Otherwise start a net/http server using path prefix and address.\n  - path prefix is used to strip the prefix from the request path.\n\n### ridge.ToRequestV1(*http.Request)\n\n`ridge.ToRequestV1(*http.Request)` converts a net/http.Request to an API Gateway V1 event payload.\n\nThis function helps call your ridge application handler directly from another service that can invoke Lambda.\n\nFor example, you can invoke ridge application on Lambda from EventBridge, Step Functions, or another Lambda function with the payload that `ridge.ToRequestV1` returns.\n\n```go\nreq, _ := http.NewRequest(\"GET\", \"http://example.com/hello?name=ridge\", nil)\npayload, _ := ridge.ToRequestV1(req)\nb, _ := json.Marshal(payload)\ninput := \u0026lambda.InvokeInput{\n\tFunctionName:   aws.String(\"your-ridge-function\"),\n\tInvocationType: types.InvocationTypeRequestResponse,\n\tPayload:        b,\n}\nresult, _ := svc.Invoke(input)\n// ...\n```\n\n### ridge.ToRequestV2(*http.Request)\n\n`ridge.ToRequestV2(*http.Request)` converts a net/http.Request to an API Gateway V2 event payload.\n\n### ridge.IsOnLambdaRuntime()\n\nIsOnLambdaRuntime returns true if running on AWS Lambda runtime (excludes on Lambda extensions).\n\n- `AWS_EXECUTION_ENV` is set on AWS Lambda runtime (go1.x).\n- `AWS_LAMBDA_RUNTIME_API` is set on custom runtime (provided.*).\n- `_HANDLER` is not set on AWS Lambda extension.\n\n#### AWS Lambda request headers\n\nWhen an application runs on AWS Lambda environments, ridge sets the following headers to the request.\n\n- `Lambda-Runtime-Aws-Request-Id`\n- `Lambda-Runtime-Invoked-Function-Arn`\n\nThese headers are from the [Lambda runtime API](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html).\n\n### Custom request builder\n\nYou can use a custom request builder to convert the AWS Lambda invoke payload to net/http.Request.\n\n```go\nr := ridge.New(\":8080\", \"/\", mux)\nr.RequestBuilder = func(payload json.RawMessage) (*http.Request, error) {\n    // your custom request builder\n}\nr.RunWithContext(ctx)\n```\n\ndefault request builder is `ridge.NewRequest`.\n\n### SIGTERM handler\n\nridge catches SIGTERM and stops the server gracefully by default.\n\nYou can add a custom handler to the SIGTERM signal.\n\n```go\nr := ridge.New(\":8080\", \"/\", mux)\nr.SIGTERMHandler = func() {\n\t// your custom handler\n}\nr.RunWithContext(ctx)\n```\n\nridge calls the handler when it receives a SIGTERM signal. After the handler returns, ridge stops the server.\n\n**Note**\n\nWhen you run ridge on AWS Lambda, ridge uses [`lambda.WithEnableSIGTERM`](https://pkg.go.dev/github.com/aws/aws-lambda-go/lambda#WithEnableSIGTERM) to call the handler.\n\nYou must add [Lambda external extensions](https://docs.aws.amazon.com/lambda/latest/dg/lambda-extensions.html) at least one to the handler. If without extensions, the handler will not be called because the Lambda runtime does not send the SIGTERM signal.\n\nThe handler must return in 500ms.\n\n### Lambda response streaming support\n\nridge supports Lambda response streaming. See [Response streaming for Lambda functions](https://docs.aws.amazon.com/lambda/latest/dg/configuration-response-streaming.html).\n\n`RIDGE_STREAMING_RESPONSE` environment variable is used to enable the streaming response. If the environment variable is set to `1` or `true`, ridge enables the streaming response.\n\nIn this case, you **must** set `InvokeMode` to `RESPONSE_STREAM` in your Lambda function URLs config. Otherwise, the function will not work.\n\nSee also [Invoking a response streaming enabled function using Lambda function URLs](https://docs.aws.amazon.com/lambda/latest/dg/config-rs-invoke-furls.html).\n\nA example of ridge application with streaming response is below.\n\n```go\nfunc main() {\n    var mux = http.NewServeMux()\n    mux.HandleFunc(\"/\", handleStream)\n    ridge.Run(\":8080\", \"/\", mux)\n}\n\nfunc handleStream(w http.ResponseWriter, r *http.Request) {\n    w.Header().Set(\"Content-Type\", \"text/plain\")\n    flusher, ok := w.(http.Flusher)\n    if !ok {\n        panic(\"expected http.ResponseWriter to be an http.Flusher\")\n    }\n    for i := 1; i \u003c= 3; i++ {\n        fmt.Fprintf(w, \"Chunk #%d\\n\", i)\n        flusher.Flush()\n        time.Sleep(time.Second)\n    }\n}\n```\n\nThis application works on AWS Lambda(streaming response mode) and also as a standalone HTTP server.\n\n## LICENSE\n\nThe MIT License (MIT)\n\nCopyright (c) 2016- FUJIWARA Shunichiro\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffujiwara%2Fridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffujiwara%2Fridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffujiwara%2Fridge/lists"}