{"id":18073381,"url":"https://github.com/blakewilliams/viewproxy","last_synced_at":"2025-04-12T05:15:40.829Z","repository":{"id":39146031,"uuid":"371180698","full_name":"BlakeWilliams/viewproxy","owner":"BlakeWilliams","description":"Experimental Go service for parallelizing application code","archived":false,"fork":false,"pushed_at":"2024-10-10T18:25:10.000Z","size":369,"stargazers_count":12,"open_issues_count":4,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T05:15:28.296Z","etag":null,"topics":[],"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/BlakeWilliams.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":"2021-05-26T22:11:03.000Z","updated_at":"2024-10-10T18:25:15.000Z","dependencies_parsed_at":"2024-06-19T03:08:56.940Z","dependency_job_id":null,"html_url":"https://github.com/BlakeWilliams/viewproxy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlakeWilliams%2Fviewproxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlakeWilliams%2Fviewproxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlakeWilliams%2Fviewproxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlakeWilliams%2Fviewproxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BlakeWilliams","download_url":"https://codeload.github.com/BlakeWilliams/viewproxy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248519557,"owners_count":21117761,"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","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":"2024-10-31T10:06:41.380Z","updated_at":"2025-04-12T05:15:40.789Z","avatar_url":"https://github.com/BlakeWilliams.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# viewproxy\n\n`viewproxy` is a Go service that makes multiple requests to an application in parallel, fetching HTML content and stitching it together to serve to a user.\n\nThis is alpha software, and is currently a proof of concept used in conjunction with Rails and View Component as a performance optimization.\n\n## Usage\n\nSee `cmd/demo/main.go` for an example of how to use the package.\n\nTo use `viewproxy`:\n\n```go\nimport \"github.com/blakewilliams/viewproxy\"\nimport \"github.com/blakewilliams/viewproxy/pkg/fragment\"\n\n// Create and configure a new Server Instance\nserver := viewproxy.NewServer(target)\nserver.Port = 3005\nserver.ProxyTimeout = time.Duration(5) * time.Second\nserver.PassThrough = true\n\n// Define a route with a :name parameter that will be forwarded to the target host.\n// This will make a layout request and 3 fragment requests, one for the header, hello, and footer.\n\n// GET http://localhost:3000/_view_fragments/layouts/my_layout?name=world\nmyPage := fragment.Define(\"my_layout\", fragment.WithChildren(fragment.Children{\n\t\"header\": fragment.Define(\"header\"), // GET http://localhost:3000/_view_fragments/header?name=world\n\t\"hello\": fragment.Define(\"hello\"),  // GET http://localhost:3000/_view_fragments/hello?name=world\n\t\"footer\" fragment.Define(\"footer\"), // GET http://localhost:3000/_view_fragments/footer?name=world\n}))\nserver.Get(\"/hello/:name\", myPage)\n\nserver.ListenAndServe()\n```\n\nEach child fragment is replaced in the parent fragment via a special tag,\n`\u003cviewproxy-fragment\u003e`. For example, the `header` fragment will be inserted into the\n`my_layout` fragment by looking for the following content: `\u003cviewproxy-fragment id=\"header\"\u003e\u003c/viewproxy-fragment\u003e`.\n\n## Demo Usage\n\n- The port the server is bound to `3005` by default but can be set via the `PORT` environment variable.\n- The target server can be set via the `TARGET` environment variable.\n  - The default is `localhost:3000/_view_fragments`\n  - `viewproxy` will call that end-point with the fragment name being passed as a query parameter. e.g. `localhost:3000/_view_fragments?fragment=header`\n\nTo run `viewproxy`, run `go build ./cmd/demo \u0026\u0026 ./demo`\n\n## Tracing with Open Telemetry\n\nYou can use tracing to learn which fragment(s) are slowest for a given page, so you know where to optimize.\n\nTo set up distributed tracing via [Open Telemetry](https://opentelemetry.io), [configure a tracing provider](https://opentelemetry.io/docs/instrumentation/go/getting-started/) in your application that uses viewproxy, and viewproxy will use the default trace provider to create spans.\n\n### Tracing attributes via fragment metadata\n\nEach fragment can be configured with a static map of key/values, which will be set as tracing attributes when each fragment is fetched.\n\n```go\nlayout := fragment.Define(\"my_layout\")\nserver.Get(\"/hello/:name\", layout, fragment.Collection{\n\tfragment.Define(\"header\", fragment.WithMetadata(map[string]string{\"page\": \"homepage\"})), // spans will have a \"page\" attribute with value \"homepage\"\n})\n```\n\n## Philosophy\n\n`viewproxy` is a simple service designed to sit between a browser request and a web application. It is used to break pages down into fragments that can be rendered in parallel for faster response times.\n\n- `viewproxy` is not coupled to a specific application framework, but _is_ being driven by close integration with Rails applications.\n- `viewproxy` should rely on Rails' (or other target application framework) strengths when possible.\n- `viewproxy` itself and its client API's should focus on developer happiness and productivity.\n\n## Development\n\nRun the tests:\n\n```sh\ngo test ./...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblakewilliams%2Fviewproxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblakewilliams%2Fviewproxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblakewilliams%2Fviewproxy/lists"}