{"id":42879676,"url":"https://github.com/bearaujus/brouter","last_synced_at":"2026-01-30T14:27:58.668Z","repository":{"id":62867035,"uuid":"561171953","full_name":"bearaujus/brouter","owner":"bearaujus","description":"Bearaujus Router (brouter) is a golang router that make your service run even more easier!","archived":false,"fork":false,"pushed_at":"2022-11-18T14:09:07.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-21T07:39:36.354Z","etag":null,"topics":["api","bearaujus","brouter","golang","rest-api","router"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bearaujus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-11-03T05:21:53.000Z","updated_at":"2022-11-18T17:44:22.000Z","dependencies_parsed_at":"2023-01-22T17:45:43.897Z","dependency_job_id":null,"html_url":"https://github.com/bearaujus/brouter","commit_stats":null,"previous_names":["bearaujus/go-simple-router"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bearaujus/brouter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bearaujus%2Fbrouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bearaujus%2Fbrouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bearaujus%2Fbrouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bearaujus%2Fbrouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bearaujus","download_url":"https://codeload.github.com/bearaujus/brouter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bearaujus%2Fbrouter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28914146,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T12:13:43.263Z","status":"ssl_error","status_checked_at":"2026-01-30T12:13:22.389Z","response_time":66,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["api","bearaujus","brouter","golang","rest-api","router"],"created_at":"2026-01-30T14:27:58.356Z","updated_at":"2026-01-30T14:27:58.641Z","avatar_url":"https://github.com/bearaujus.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BROUTER\nBearaujus Router (brouter) is a golang router that make your service run even more easier!\n\n# Installation\n`go get github.com/Bearaujus/brouter`\n\n# Example: Simple Usecase\n- Code\n```go\npackage main\n\nimport (\n\t\"github.com/Bearaujus/brouter\"\n\t\"github.com/sirupsen/logrus\"\n\t\"net/http\"\n)\n\nfunc main() {\n\t// create new brouter instance\n\trouter := brouter.NewBRouter()\n\n\t// add route\n\trouter.Route(brouter.StructRoute{\n\t\tPattern:     \"/test\",\n\t\tMethods:     []string{http.MethodGet, http.MethodOptions},\n\t\tHandlerFunc: SampleHandler,\n\t})\n\n\t// serve http\n\terr := router.Serve(\"127.0.0.1\", 25565)\n\tif err != nil {\n\t\tlogrus.Info(err)\n\t}\n}\n\ntype Foo struct {\n\tBar    string\n\tSample string\n}\n\nfunc SampleHandler(w http.ResponseWriter, r *http.Request) (interface{}, error) {\n\tmodel := Foo{\n\t\tBar:    \"test-bar\",\n\t\tSample: \"test-sample\",\n\t}\n\n\t// you can pass directly any data type to the handler!\n\treturn model, nil\n}\n```\n\n- Response\n```json\n{\n    \"header\": {\n        \"is_success\": true\n    },\n    \"data\": {\n        \"Bar\": \"test-bar\",\n        \"Sample\": \"test-sample\"\n    }\n}\n```\n\n# Example: Route File Server\n- Code\n```go\npackage main\n\nimport (\n\t\"github.com/Bearaujus/brouter\"\n\t\"github.com/sirupsen/logrus\"\n)\n\nfunc main() {\n\t// create new brouter instance\n\trouter := brouter.NewBRouter()\n\n\t// route file server\n\trouter.RouteFileServer(brouter.StructRouteFileServer{\n\t\tPattern: \"/fs\",\n\t\tDirPath: \"./\",\n\t})\n\n\t// serve http\n\terr := router.Serve(\"127.0.0.1\", 25565)\n\tif err != nil {\n\t\tlogrus.Info(err)\n\t}\n}\n```\n\n- Response\n\nYour file server at `DirPath` can be accessed from `Pattern`.\n\n# Example: Overriding Default Handler Success / Error Func\n- Code\n```go\npackage main\n\nimport (\n\t\"encoding/json\"\n\t\"errors\"\n\t\"github.com/Bearaujus/brouter\"\n\t\"github.com/sirupsen/logrus\"\n\t\"net/http\"\n)\n\nfunc main() {\n\t// create new brouter instance\n\trouter := brouter.NewBRouter()\n\n\t// overriding default handler error func\n\trouter.SetDefaultHandlerErrorFunc(HandlerErrorFunc)\n\n\t// overriding default handler success func\n\trouter.SetDefaultHandlerSuccessFunc(HandlerSuccessFunc)\n\n\t// add routes\n\trouter.Routes([]brouter.StructRoute{\n\t\t{\n\t\t\tPattern:     \"/success\",\n\t\t\tMethods:     []string{http.MethodGet, http.MethodOptions},\n\t\t\tHandlerFunc: SampleHandlerSuccess,\n\t\t},\n\t\t{\n\t\t\tPattern:     \"/error\",\n\t\t\tMethods:     []string{http.MethodGet, http.MethodOptions},\n\t\t\tHandlerFunc: SampleHandlerError,\n\t\t},\n\t})\n\n\t// serve http\n\terr := router.Serve(\"127.0.0.1\", 25565)\n\tif err != nil {\n\t\tlogrus.Info(err)\n\t}\n}\n\ntype Foo struct {\n\tBar    string\n\tSample string\n}\n\nfunc SampleHandlerSuccess(w http.ResponseWriter, r *http.Request) (interface{}, error) {\n\tmodel := Foo{\n\t\tBar:    \"test-bar\",\n\t\tSample: \"test-sample\",\n\t}\n\n\treturn model, nil\n}\n\nfunc SampleHandlerError(w http.ResponseWriter, r *http.Request) (interface{}, error) {\n\treturn nil, errors.New(\"sample error\")\n}\n\nfunc HandlerErrorFunc(w http.ResponseWriter, r *http.Request, err error) {\n\tw.Header().Set(\"Content-Type\", \"text/plain\")\n\n\tw.WriteHeader(http.StatusBadRequest)\n\t_, _ = w.Write([]byte(err.Error()))\n}\n\nfunc HandlerSuccessFunc(w http.ResponseWriter, r *http.Request, data interface{}) {\n\tpayload, _ := json.Marshal(data)\n\n\tw.Header().Set(\"Content-Type\", \"text/plain\")\n\n\tw.WriteHeader(http.StatusOK)\n\t_, _ = w.Write(payload)\n}\n```\n\n- Success Response\n```text\n{\"Bar\":\"test-bar\",\"Sample\":\"test-sample\"}\n```\n\n- Error Response\n```text\nsample error\n```\n\n# Example: Overwriting Handler Success / Error Func\nIf you set default success / error handler. This is more prioritized to be executed.\n- Code\n```go\npackage main\n\nimport (\n\t\"encoding/json\"\n\t\"errors\"\n\t\"github.com/Bearaujus/brouter\"\n\t\"github.com/sirupsen/logrus\"\n\t\"net/http\"\n)\n\nfunc main() {\n\t// create new brouter instance\n\trouter := brouter.NewBRouter()\n\n\t// add routes\n\trouter.Routes([]brouter.StructRoute{\n\t\t{\n\t\t\tPattern:     \"/success\",\n\t\t\tMethods:     []string{http.MethodGet, http.MethodOptions},\n\t\t\tHandlerFunc: SampleHandlerSuccess,\n\t\t\t// set handler error func\n\t\t\tHandlerErrorFunc: HandlerErrorFunc,\n\t\t\t// set handler success func\n\t\t\tHandlerSuccessFunc: HandlerSuccessFunc,\n\t\t},\n\t\t{\n\t\t\tPattern:     \"/error\",\n\t\t\tMethods:     []string{http.MethodGet, http.MethodOptions},\n\t\t\tHandlerFunc: SampleHandlerError,\n\t\t\t// set handler error func\n\t\t\tHandlerErrorFunc: HandlerErrorFunc,\n\t\t\t// set handler success func\n\t\t\tHandlerSuccessFunc: HandlerSuccessFunc,\n\t\t},\n\t})\n\n\t// serve http\n\terr := router.Serve(\"127.0.0.1\", 25565)\n\tif err != nil {\n\t\tlogrus.Info(err)\n\t}\n}\n\ntype Foo struct {\n\tBar    string\n\tSample string\n}\n\nfunc SampleHandlerSuccess(w http.ResponseWriter, r *http.Request) (interface{}, error) {\n\tmodel := Foo{\n\t\tBar:    \"test-bar\",\n\t\tSample: \"test-sample\",\n\t}\n\n\treturn model, nil\n}\n\nfunc SampleHandlerError(w http.ResponseWriter, r *http.Request) (interface{}, error) {\n\treturn nil, errors.New(\"sample error\")\n}\n\nfunc HandlerErrorFunc(w http.ResponseWriter, r *http.Request, err error) {\n\tw.Header().Set(\"Content-Type\", \"text/plain\")\n\n\tw.WriteHeader(http.StatusBadRequest)\n\t_, _ = w.Write([]byte(err.Error()))\n}\n\nfunc HandlerSuccessFunc(w http.ResponseWriter, r *http.Request, data interface{}) {\n\tpayload, _ := json.Marshal(data)\n\n\tw.Header().Set(\"Content-Type\", \"text/plain\")\n\n\tw.WriteHeader(http.StatusOK)\n\t_, _ = w.Write(payload)\n}\n```\n\n- Success Response\n```text\n{\"Bar\":\"test-bar\",\"Sample\":\"test-sample\"}\n```\n\n- Error Response\n```text\nsample error\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbearaujus%2Fbrouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbearaujus%2Fbrouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbearaujus%2Fbrouter/lists"}