{"id":13764102,"url":"https://github.com/fulldump/golax","last_synced_at":"2025-12-30T01:05:49.509Z","repository":{"id":44638538,"uuid":"50740314","full_name":"fulldump/golax","owner":"fulldump","description":"Golax, a go implementation for the Lax framework.","archived":false,"fork":false,"pushed_at":"2023-01-11T00:34:09.000Z","size":2227,"stargazers_count":75,"open_issues_count":6,"forks_count":7,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-11-16T23:32:36.540Z","etag":null,"topics":[],"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/fulldump.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["fulldump"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2016-01-30T19:11:39.000Z","updated_at":"2023-09-27T21:43:32.000Z","dependencies_parsed_at":"2023-02-08T21:00:51.854Z","dependency_job_id":null,"html_url":"https://github.com/fulldump/golax","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fulldump%2Fgolax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fulldump%2Fgolax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fulldump%2Fgolax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fulldump%2Fgolax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fulldump","download_url":"https://codeload.github.com/fulldump/golax/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253453343,"owners_count":21911081,"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-08-03T15:01:13.866Z","updated_at":"2025-12-30T01:05:49.482Z","avatar_url":"https://github.com/fulldump.png","language":"Go","funding_links":["https://github.com/sponsors/fulldump"],"categories":["web框架","Web框架","Web Frameworks","web框架`web 框架`","Utility"],"sub_categories":["版本控制","实用程序/Miscellaneous","HTTP Clients","Utility/Miscellaneous","Fail injection","版本控制`版本控制相关库`","Advanced Console UIs","交流"],"readme":"\u003cimg src=\"logo.png\"\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://app.travis-ci.com/fulldump/golax\"\u003e\u003cimg src=\"https://app.travis-ci.com/fulldump/golax.svg?branch=master\"\u003e\u003c/a\u003e\n\u003ca href=\"https://goreportcard.com/report/github.com/fulldump/golax\"\u003e\u003cimg src=\"https://goreportcard.com/badge/github.com/fulldump/golax\"\u003e\u003c/a\u003e\n\u003ca href=\"https://godoc.org/github.com/fulldump/golax\"\u003e\u003cimg src=\"https://godoc.org/github.com/fulldump/golax?status.svg\" alt=\"GoDoc\"\u003e\u003c/a\u003e\n\u003ca href=\"https://codeclimate.com/github/fulldump/golax/maintainability\"\u003e\u003cimg src=\"https://api.codeclimate.com/v1/badges/798baff13203d5a4abad/maintainability\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nGolax is the official go implementation for the _Lax_ framework.\n\n\u003c!-- MarkdownTOC autolink=true bracket=round depth=4 --\u003e\n\n- [About Lax](#about-lax)\n- [Getting started](#getting-started)\n- [Routing example](#routing-example)\n- [Performance](#performance)\n- [How interceptor works](#how-interceptor-works)\n- [Handling parameters](#handling-parameters)\n- [Support for Google custom methods](#support-for-google-custom-methods)\n- [Sample use cases](#sample-use-cases)\n\n\u003c!-- /MarkdownTOC --\u003e\n\nRelated docs:\n\n* [Developer notes](doc/developer.md)\n* [TODO list](doc/todo.md)\n\n## About Lax\n\nLax wants to be the best _\"user experience\"_ for developers making REST APIs.\n\nThe design principles for _Lax_ are:\n\n* The lowest language overhead\n* Extremely fast to develop\n* Very easy to read and trace.\n\n\n## Getting started\n\n```go\nmy_api := golax.NewApi()\n\nmy_api.Root.\n    Interceptor(golax.InterceptorError).\n    Interceptor(myLogingInterceptor)\n\nmy_api.Root.Node(\"hello\").\n    Method(\"GET\", func(c *golax.Context) {\n        // At this point, Root interceptors has been already executed\n        fmt.Fprintln(c.Response, \"Hello world!\")\n    })\n\nmy_api.Serve()\n```\n\n## Routing example\n\nRouting is based on nodes.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"doc/figure_4_routing_example.png\"\u003e\n\u003c/p\u003e\n\nThere are three types: `static`, `regex` and `parameter`.\n\n* static: Only matches with the url part if it is exactly the same.\n* regex: Surrounded by `(` and `)`, if the regex match.\n* parameter: Surrounded by `{` and `}`, always matches.\n\n## Performance\n\nThe performance compared with the [most popular alternative](http://www.gorillatoolkit.org/) is very similar (actually _golax_ performs slightly better) however code readability and maintainability is far better with _golax_ implementation.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"doc/figure_3_performance.png\"\u003e\n\u003c/p\u003e\n\nTests has been executed in a `Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz`.\n\nLearn more about this https://github.com/fulldump/golax-performance.\n\n## How interceptor works\n\nIf I want to handle a `GET /users/1234/stats` request, all interceptors in nodes from `\u003croot\u003e` to `.../stats` are executed:\n\n![Normal flow](doc/figure_1_normal_flow.png)\n\nTo abort the execution, call to `c.Error(404, \"Resource not found\")`:\n\n![Break flow](doc/figure_2_break_flow.png)\n\n## Handling parameters\n\n```go\nmy_api := golax.NewApi()\n\nmy_api.Root.\n    Node(\"users\").\n    Node(\"{user_id}\").\n    Method(\"GET\", func (c *golax.Context) {\n        fmt.Fprintln(c.Response, \"You are looking for user \" + c.Parameter)\n    })\n\nmy_api.Serve()\n```\n\nIt is also possible get all parameters:\n\n```go\nfunc (c *golax.Context) {\n    fmt.Fprintln(c.Response, \"All parameters:\", c.Parameters)\n}\n```\n\n## Support for Google custom methods\n\nAccording to Google's API design guidelines to map RPC services to REST HTTP,\nit describes custom methods as extra operations that can not be easyly mapped\nto HTTP verbs. [More info about custom methods](https://cloud.google.com/apis/design/custom_methods)\n\nFor example, this URL has a custom method `:activate`:\n\n```\nhttps://my.service.com/v1/users/31231231231:activate\n```\n\nGolax support custom methods as operations:\n\n```go\nmy_api.Root.\n    Node(\"v1\").\n    Node(\"users\").\n    Node(\"{user_id}\").\n    Operation(\"activate\").\n    Method(\"POST\", func(c *golax.Context) {\n        user_id := c.Parameters[\"{user_id}\"]\"\n        fmt.Fprintln(c.Response, \"Here is custom method ':activate' for user \"+user_id)\n    })\n```\n\n\n## Sample use cases\n\nTODO: put here some examples to cover cool things:\n\n* fluent implementation\n* node cycling\n* readability\n* node preference\n* sample logging interceptor\n* sample auth interceptor\n* sample api errors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffulldump%2Fgolax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffulldump%2Fgolax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffulldump%2Fgolax/lists"}