{"id":34209918,"url":"https://github.com/joseph-beck/routey","last_synced_at":"2026-05-29T17:31:41.714Z","repository":{"id":205468588,"uuid":"714124197","full_name":"joseph-beck/routey","owner":"joseph-beck","description":"a simple HTTP Go router","archived":false,"fork":false,"pushed_at":"2024-04-26T14:46:20.000Z","size":103,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-19T01:25:03.070Z","etag":null,"topics":["go","http"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/joseph-beck/routey","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/joseph-beck.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-11-04T01:32:09.000Z","updated_at":"2024-04-26T14:46:20.000Z","dependencies_parsed_at":"2024-03-16T14:31:31.201Z","dependency_job_id":"93bf2243-47e2-48fd-b924-b9fccb16625d","html_url":"https://github.com/joseph-beck/routey","commit_stats":null,"previous_names":["joseph-beck/routey"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/joseph-beck/routey","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joseph-beck%2Froutey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joseph-beck%2Froutey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joseph-beck%2Froutey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joseph-beck%2Froutey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joseph-beck","download_url":"https://codeload.github.com/joseph-beck/routey/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joseph-beck%2Froutey/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33664259,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-29T02:00:06.066Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["go","http"],"created_at":"2025-12-15T20:56:49.347Z","updated_at":"2026-05-29T17:31:41.701Z","avatar_url":"https://github.com/joseph-beck.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"![GitHub go.mod Go version (subdirectory of monorepo)](https://img.shields.io/github/go-mod/go-version/joseph-beck/routey) \n![GitHub License](https://img.shields.io/github/license/joseph-beck/routey)\n![GitHub release (with filter)](https://img.shields.io/github/v/release/joseph-beck/routey)\n![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/joseph-beck/routey/.github%2Fworkflows%2Fgo.yml)\n\n# routey\n\nAn extremely simple Go HTTP Router made for fun! This was heavily inspired by gin.\n\n## Installation\n\n```sh\n$ go get -u github.com/joseph-beck/routey\n```\n\n```go\nimport (\n    route \"github.com/joseph-beck/routey/pkg/router\"\n)\n```\n\n## Examples\n\n### Getting Started\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"net/http\"\n\n    routey \"github.com/joseph-beck/routey/pkg/router\"\n)\n\nfunc main() {\n    r := routey.New()\n    go r.Shutdown()\n\n    r.Route(routey.Route{\n        Path: \"/hello\",\n        Params: \"\",\n        Method: routey.Get,\n        HandleFunc: func(c *routey.Context) {\n            b := \"Hello world!\"\n            c.Render(http.StatusOK, b)\n        }\n        DecoratorFunc: nil,\n    })\n\n    r.Run()\n}\n```\n\nPlease note that routes defined before others will have precedence, for example a route of /api/:id will have complete precedence over a route /api/ping even if the route /api/ping is called.\n\n```go\nfunc main() {\n    c := routey.Config{\n        Port:  \":3000\",\n        Debug: true,\n        CORS:  false,\n    }\n\n    r := routey.New(c)\n}\n```\n\nRoutey also has a few configuration options, and hopefully more to come in the future, that allow you to manipulate modes and the ports used.\n\n### Using parameters\n\n```go\nfunc handler() routey.HandlerFunc {\n    return func(c *routey.Context) {\n        p, err := c.Param(\"param\")\n        if err != nil {\n            c.Status(http.BadRequest)\n            return\n        }\n\n        c.Render(http.StatusOK, p)\n    }\n}\n\nr.Add(\n    \"/route\",\n    \"/:param\",\n    routey.Get,\n    handler(),\n    nil,\n)\n```\n\n### Using queries\n\n```go\nfunc handler() routey.HandlerFunc {\n    return func(c *routey.Context) {\n        q, err := c.Query(\"query\")\n        if err != nil {\n            c.Status(http.BadRequest)\n            return\n        }\n\n        c.Render(http.StatusOK, q)\n    }\n}\n```\n\n### Creating a HandlerFunc\n\n```go\nfunc handler() routey.HandlerFunc {\n    return func(c *routey.Context) {\n        b := \"I am a handler!\"\n        c.Render(http.StatusOK, b)\n    }\n}\n```\n\nDeclaring a handler function this way allows us to more easily use dependency injection.\n\n### Creating a DecoratorFunc\n\n```go\nfunc decorator(f routey.HandlerFunc) routey.HandlerFunc {\n    return func(c *routey.Context) {\n        fmt.Println(\"I am a decorator!\")\n        f(c)\n    }\n}\n```\n\nDeclaring a decorator function this way allows us to decorate decorator functions as well as more easily use dependency injection. They can be used for a variety of things, but commonly used in protecting our end points.\n\n### Adding Middleware\n\n```go\nfunc middleware() routey.MiddlewareFunc {\n    return (c *routey.Context) {\n        fmt.Println(\"I am middleware!\")\n    }\n}\n\nfunc main() {\n    r := routey.New()\n    r.Use(middleware())\n}\n```\n\nAlthough Routey has more of an emphasis on using Decorators, Middleware is a great option for something you would like to use on all of your routes. It uses the same context as the Handler will use so values can even be communicated between the Middleware and Handler.\n\n### Services\n\nroutey also supports the use of Services, which are structs with methods that are your endpoints, every Service must implement an `Add() []Route` that can be registered to the App with the `Register()` method.\n\n```go\ntype HelloService struct{}\n\nfunc (s HelloService) Add() []Route {\n    return []Route{\n        {\n            Path:          \"/hello\",\n            Params:        \"\",\n            Method:        Get,\n            HandlerFunc:   s.Get(),\n            DecoratorFunc: nil,\n        },\n    }\n}\n\nfunc (s *HelloService) Get() HandlerFunc {\n    return func(c *Context) {\n        c.Status(http.StatusOK)\n    }\n}\n```\n\nWhen creating instances of your Service you can give dependencies to the struct for example a database connection, etc.\n\n### Rendering HTML\n\n```go\nfunc main() {\n    ...\n    r.LoadHTMLGlob(\"web/*\")\n    ...\n}\n\n// /index\nfunc indexHandler() routey.HandlerFunc {\n    return func(c *routey.Context) {\n        c.HTML(\n            http.StatusOK,\n            \"index.html\",\n            nil,\n        )\n    }\n}\n\n// /name/:name\nfunc helloHandler() routey.HandlerFunc {\n    return func(c *routey.Context) {\n        name, err := c.Param(\"name\")\n        if err != nil {\n            c.Status(http.StatusBadRequest)\n            return\n        }\n\n        c.HTML(\n            http.StatusOK,\n            \"hello.html\",\n            routey.M{\n                \"name\": name,\n            },\n        )\n    }\n}\n```\n\nWe can render HTML pages by loading a glob, or group of HTML files in a directory, or just specific files. The endpoints are added to the App just like any other endpoint. We can link HTML pages together by creating an endpoint for another HTML file and using a href to that, for example:\n\n***index.html***\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003cbody\u003e\n\n\u003ch1\u003eRoutey\u003c/h1\u003e\n\u003ca href=\"/hello\"\u003ehello\u003ca/\u003e\n\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n***hello.html***\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003cbody\u003e\n\n\u003cp\u003eHello {{ .name }}\u003cp\u003e\n\u003ca href=\"/index\"\u003ehome\u003ca/\u003e\n\n\u003c/body\u003e\n\u003c/html\u003e\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoseph-beck%2Froutey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoseph-beck%2Froutey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoseph-beck%2Froutey/lists"}