{"id":13764096,"url":"https://github.com/claygod/Bxog","last_synced_at":"2025-05-10T17:31:38.088Z","repository":{"id":57481108,"uuid":"59203554","full_name":"claygod/Bxog","owner":"claygod","description":"Bxog is a simple and fast HTTP router for Go (HTTP request multiplexer).","archived":false,"fork":false,"pushed_at":"2022-09-07T17:51:09.000Z","size":67,"stargazers_count":102,"open_issues_count":0,"forks_count":8,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-10-25T05:26:13.951Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/claygod.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-19T12:20:08.000Z","updated_at":"2024-09-27T11:48:34.000Z","dependencies_parsed_at":"2022-09-26T17:50:38.587Z","dependency_job_id":null,"html_url":"https://github.com/claygod/Bxog","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/claygod%2FBxog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claygod%2FBxog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claygod%2FBxog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claygod%2FBxog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/claygod","download_url":"https://codeload.github.com/claygod/Bxog/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224982988,"owners_count":17402404,"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.678Z","updated_at":"2024-11-16T23:31:09.814Z","avatar_url":"https://github.com/claygod.png","language":"Go","funding_links":[],"categories":["Web Frameworks","Go","Web框架","路由","Routers"],"sub_categories":["Routers","路由器","创建http中间件的代码库"],"readme":"Bxog is a simple and fast HTTP router for Go (HTTP request multiplexer).\n\n[![API documentation](https://godoc.org/github.com/claygod/Bxog?status.svg)](https://godoc.org/github.com/claygod/Bxog)\n[![Go Report Card](https://goreportcard.com/badge/github.com/claygod/Bxog)](https://goreportcard.com/report/github.com/claygod/Bxog)\n[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)\n\n# Usage\n\nAn example of using the multiplexer:\n```go\npackage main\n\nimport (\n\t\"io\"\n\t\"net/http\"\n\n\tbx \"github.com/claygod/Bxog\"\n)\n\n// Handlers\nfunc IHandler(w http.ResponseWriter, req *http.Request, r *bx.Router) {\n\tio.WriteString(w, \"Welcome to Bxog!\")\n}\nfunc THandler(w http.ResponseWriter, req *http.Request, r *bx.Router) {\n\tparams := r.Params(req, \"/abc/:par\")\n\tio.WriteString(w, \"Params:\\n\")\n\tio.WriteString(w, \" 'par' -\u003e \"+params[\"par\"]+\"\\n\")\n}\nfunc PHandler(w http.ResponseWriter, req *http.Request, r *bx.Router) {\n\t// Getting parameters from URL\n\tparams := r.Params(req, \"country\")\n\tio.WriteString(w, \"Country:\\n\")\n\tio.WriteString(w, \" 'name' -\u003e \"+params[\"name\"]+\"\\n\")\n\tio.WriteString(w, \" 'capital' -\u003e \"+params[\"city\"]+\"\\n\")\n\tio.WriteString(w, \" 'valuta' -\u003e \"+params[\"money\"]+\"\\n\")\n\t// Creating an URL string\n\tio.WriteString(w, \"Creating an URL from the current route (This is an example of creating an another URL):\\n\")\n\tio.WriteString(w, r.Create(\"country\", map[string]string{\"name\": \"Russia\", \"city\": \"Moscow\", \"money\": \"rouble\"}))\n}\n\n// Main\nfunc main() {\n\tm := bx.New()\n\tm.Add(\"/\", IHandler)\n\tm.Add(\"/abc/:par\", THandler)\n\tm.Add(\"/country/:name/capital/:city/valuta/:money\", PHandler).\n\t\tId(\"country\"). // For a convinience you can indicate a short ID\n\t\tMethod(\"GET\")  // It is not necessary to indicate the GET method here as the GET method is used by default but this way is used to set an allowed method\n\tm.Test()\n\tm.Start(\":9999\")\n}\n\n```\n\nClick URLs:\n- http://localhost:9999\n- http://localhost:9999/abc/123\n- http://localhost:9999/country/USA/capital/Washington/valuta/dollar\n\n# Settings\n\nNecessary changes in the configuration of the multiplexer can be made in the configuration file [config.go](https://github.com/claygod/Bxog/blob/master/config.go)\n\n# Perfomance\n\nBxog is the fastest router, showing the speed of query processing. Its speed is comparable to the speed of the popular multiplexers: Bone, Httprouter, Gorilla, Zeus. The test is done on a computer with a i3-6320 3.7GHz processor and 8 GB RAM. In short (less time, the better):\n\n- Bxog 163 ns/op\n- HttpRouter 183 ns/op\n- Zeus 12302 ns/op\n- GorillaMux 14928 ns/op\n- GorillaPat 618 ns/op\n- Bone 47333 ns/op\n\nDetailed benchmark [here](https://github.com/claygod/BxogTest)\n\n# API\n\nMethods:\n-  *New* - create a new multiplexer\n-  *Add* - add a rule specifying the handler (the default method - GET, ID - as a string to this rule)\n-  *Start* - start the server indicating the listening port\n-  *Params* - extract parameters from URL\n-  *Create* - generate URL of the available options\n-  *Shutdown* - graceful stop the server\n-  *Stop* - aggressive stop the server\n-  *Test* - Start analogue (for testing only)\n\nExample:\n`\n\tm := bxog.New()\n\tm.Add(\"/\", IHandler)\n`\n\n# Named parameters\n\nArguments in the rules designated route colon. Example route: */abc/:param* , where *abc* is a static section and *:param* - the dynamic section(argument).\n\n# Static files\n\nThe directory path to the file and its nickname as part of URL specified in the configuration file. This constants *FILE_PREF* and *FILE_PATH*\n\n# Copyright\n\nCopyright © 2016-2022 Eduard Sesigin. All rights reserved. Contacts: \u003cclaygod@yandex.ru\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclaygod%2FBxog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclaygod%2FBxog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclaygod%2FBxog/lists"}