{"id":27775766,"url":"https://github.com/aileron-gateway/example-extension","last_synced_at":"2025-08-24T17:09:19.564Z","repository":{"id":290039917,"uuid":"973145045","full_name":"aileron-gateway/example-extension","owner":"aileron-gateway","description":"Example project to entend AILERON Gateway","archived":false,"fork":false,"pushed_at":"2025-06-16T11:15:44.000Z","size":75,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-01T12:20:36.580Z","etag":null,"topics":["aileron-gateway","api-gateway","example","go"],"latest_commit_sha":null,"homepage":"https://aileron-gateway.github.io/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aileron-gateway.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,"zenodo":null}},"created_at":"2025-04-26T11:05:00.000Z","updated_at":"2025-06-16T11:15:47.000Z","dependencies_parsed_at":"2025-04-26T14:23:00.330Z","dependency_job_id":"16cc0372-fac8-453b-aad4-e6c02e5debf0","html_url":"https://github.com/aileron-gateway/example-extension","commit_stats":null,"previous_names":["aileron-gateway/example-extension"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aileron-gateway/example-extension","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aileron-gateway%2Fexample-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aileron-gateway%2Fexample-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aileron-gateway%2Fexample-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aileron-gateway%2Fexample-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aileron-gateway","download_url":"https://codeload.github.com/aileron-gateway/example-extension/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aileron-gateway%2Fexample-extension/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271910562,"owners_count":24842368,"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-08-24T02:00:11.135Z","response_time":111,"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":["aileron-gateway","api-gateway","example","go"],"created_at":"2025-04-30T04:21:42.021Z","updated_at":"2025-08-24T17:09:19.520Z","avatar_url":"https://github.com/aileron-gateway.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Example project extending the [AILERON Gateway](https://github.com/aileron-gateway/aileron-gateway) \u003c!-- omit in toc --\u003e\n\nThis project extend the [AILERON Gateway](https://github.com/aileron-gateway/aileron-gateway) by importing it to Go project.\n\n```mermaid\ngraph BT\n    AG(\"\u003ca style=\"color:#000\" href='https://github.com/aileron-gateway/aileron-gateway'\u003eaileron-gateway\u003c/a\u003e\")\n    EE(\"example-extension\u003c/br\u003e(This repository)\")\n    EE -- import ---\u003e AG\n    style EE fill:#ffcce5,stroke:#ff7fbf\n```\n\n**To build and run the example, follow the steps.**\n\n- [Prepare development environment](#prepare-development-environment)\n  - [1. Install Protoc](#1-install-protoc)\n  - [2. Install protoc-gen-go](#2-install-protoc-gen-go)\n  - [3. protovalidate](#3-protovalidate)\n- [Write code](#write-code)\n- [Build binary](#build-binary)\n  - [1. Generate Go code from proto](#1-generate-go-code-from-proto)\n  - [2. Build binary](#2-build-binary)\n- [Run binary](#run-binary)\n\n## Prepare development environment\n\n### 1. Install [Protoc](https://github.com/protocolbuffers/protobuf)\n\nAILERON Gateway uses [protocol buffer](https://github.com/protocolbuffers/protobuf) to define configuration file interfaces.\n`protoc` command is required to generate Go codes from `*.proto` definitions.\n\n**Follow the [Protocol Buffer Compiler Installation](https://protobuf.dev/installation/) and install `protoc` command.**\n\n```bash\n$ protoc --version\nlibprotoc 29.0\n```\n\nIf you are working on linux, directory structure may becomes like follows.\n\n```txt\n/usr/\n└── local/\n    ├── bin/\n    │   └── protoc\n    └── include/\n        └── google/\n```\n\n### 2. Install [protoc-gen-go](https://pkg.go.dev/google.golang.org/protobuf)\n\nTo generate Go codes from protoc definitions, `protoc-gen-go` command is required.\n\n**Follow the [Quick start Go](https://grpc.io/docs/languages/go/quickstart/) to install protoc-gen-go.**\n\nOr, just run the following installation command.\n\n```bash\ngo install \"google.golang.org/protobuf/cmd/protoc-gen-go@latest\"\n```\n\n### 3. [protovalidate](https://github.com/bufbuild/protovalidate)\n\nAILERON Gateway uses [protovalidate](https://github.com/bufbuild/protovalidate) to apply configuration validation.\nWe need to import [validate.proto](https://github.com/bufbuild/protovalidate/blob/main/proto/protovalidate/buf/validate/validate.proto)\n\n**In this project, validate.proto is already copied into the [./proto/buf/](./proto/buf/).**\n\n## Write code\n\n- Example middleware is in [./feature/hello/](./feature/hello/).\n- Example protoc is in [./proto/ext/v1/](./proto/ext/v1/).\n\nThe example middleware adds `Hello: World!!` to the HTTP response headers.\n\n## Build binary\n\n### 1. Generate Go code from proto\n\n`protoc` should be run to generate go codes from proto definition.\n\nThe command becomes\n\n```bash\nprotoc \\\n  --proto_path ./proto\n  --proto_path=\u003cPATH_TO_AILERON_GATEWAY_REPOSITORY\u003e/proto/\n  --plugin=protoc-gen-go=\u003cABSOLUTE_PATH_TO protoc-gen-go\u003e\n  --go_out=./\n  --go_opt=module=\"github.com/aileron-gateway/example-extension\"\n  \u003cALL_PROTOC_PATH\u003e\n```\n\nFor convenience, the command can be run with [./Makefile](./Makefile).\n\n```bash\ngo get ./... # Download aileron-gateway repository.\nmake proto\n```\n\n### 2. Build binary\n\nJust run `go build` to generate `example-extension` or `example-extension.exe`.\n\n```bash\ngo build ./\n```\n\nOr, this is recommended one.\n\n```bash\nexport CGO_ENABLED=0\ngo build -trimpath -ldflags=\"-w -s -extldflags '-static'\" ./\n```\n\n## Run binary\n\n[./config.yaml](./config.yaml) is a sample configuration.\n\nIt runs a reverse proxy server which proxy requests to [http://httpbin.org](http://httpbin.org).\n\nRun the reverse proxy server with the command.\n\n```sh\n./example-extension -f config.yaml\n```\n\nThen, send a HTTP request.\n\n```sh\ncurl --head -X GET \"http://localhost:8080/get\"\n```\n\nThe `Hello: World!!` header which is added by the [./feature/hello/](./feature/hello/) exists in the header.\n\n```text\nHTTP/1.1 200 OK\nAccess-Control-Allow-Credentials: true\nAccess-Control-Allow-Origin: *\nContent-Length: 309\nContent-Type: application/json\nDate: Sat, 26 Apr 2025 13:05:51 GMT\nHello: World!!\nServer: gunicorn/19.9.0\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faileron-gateway%2Fexample-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faileron-gateway%2Fexample-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faileron-gateway%2Fexample-extension/lists"}