{"id":18307841,"url":"https://github.com/davidroman0o/querybind","last_synced_at":"2026-04-30T10:08:58.469Z","repository":{"id":206730754,"uuid":"717572372","full_name":"davidroman0O/querybind","owner":"davidroman0O","description":"Fiber utility functions to parse queryparams and preserve its state for web applications ","archived":false,"fork":false,"pushed_at":"2023-11-16T00:28:48.000Z","size":19,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T20:43:32.278Z","etag":null,"topics":["fiber","htmx","queryparameters","queryparams"],"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/davidroman0O.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":"2023-11-11T21:53:40.000Z","updated_at":"2024-04-25T12:19:57.000Z","dependencies_parsed_at":"2025-02-15T05:32:34.319Z","dependency_job_id":null,"html_url":"https://github.com/davidroman0O/querybind","commit_stats":null,"previous_names":["davidroman0o/querybind"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidroman0O%2Fquerybind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidroman0O%2Fquerybind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidroman0O%2Fquerybind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidroman0O%2Fquerybind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidroman0O","download_url":"https://codeload.github.com/davidroman0O/querybind/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248029032,"owners_count":21035930,"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":["fiber","htmx","queryparameters","queryparams"],"created_at":"2024-11-05T16:05:41.384Z","updated_at":"2026-04-30T10:08:53.448Z","avatar_url":"https://github.com/davidroman0O.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# QueryBind \n\nThe `querybind` package is a utility library for the [Fiber](https://gofiber.io/) web framework, designed to simplify query parameter binding and state management in HTMX-driven applications. It provides a way to bind query parameters to Go structs and manage URL state seamlessly.\n\n## TODO\n\n- Integrate more libs/framework, not just fiber\n- WithRedirection: might not want to use HX-Push\n- WithCustom: might want to do something custom  ¯\\_(ツ)_/¯ \n- more examples\n\n## Features\n\n- Bind URL query parameters to Go structs dynamically using struct tags.\n- Maintain and manipulate browser URL state with HTMX requests without full page reloads.\n- Provide functional options to customize the behavior of the response binding.\n\n## Installation\n\nTo use the `querybind` package in your project, run:\n\n```bash\ngo get github.com/davidroman0O/querybind\n```\n\n## Usage\n\nSee examples [querybind-example](https://github.com/davidroman0O/querybind-examples)\n\n### QueryBind\n\nBind query parameters from the request to a struct:\n\n```go\ntype FilterParams struct {\n    Genres []string `querybind:\"genres\"`\n    Years  []int    `querybind:\"years\"`\n}\n\n// ...\n\n// return refreshed html of a component\napp.Get(\"/page/component\", func(c *fiber.Ctx) error {\n    var params FilterParams\n    if err := querybind.Bind(\u0026params, c); err != nil {\n        return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{\"error\": err.Error()})\n    }\n    // Use params here...\n    // return component html\n})\n```\n\n### ResponseBind\n\nUpdate the URL state using `ResponseBind` by setting a `HX-Push-Url` response header:\n\n```go\n// return refreshed html of a component\napp.Get(\"/page/component\", func(c *fiber.Ctx) error {\n    // Assume params is populated... and you did some processing on some data, whatever\n    querybind.ResponseBind(c, params, querybind.WithPath(\"/page\")) // for the component, you might want to keep the path of the page\n    // Continue with response... that return the html\n})\n```\n\n## Options\n\nThe `ResponseBind` function can be customized with the following option:\n\n- `WithPath(path string)`: Customizes the path used in the `HX-Push-Url` header.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgements\n\n- The [Fiber](https://gofiber.io/) team for creating a fantastic web framework.\n- The creators and contributors of [HTMX](https://htmx.org/) for enabling modern, dynamic web interactions.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidroman0o%2Fquerybind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidroman0o%2Fquerybind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidroman0o%2Fquerybind/lists"}