chi v3 roadmap

Created on 12 Apr 2017  Â·  15Comments  Â·  Source: go-chi/chi

  • [x] Fix bugs #78 #100 - relating to param keys overlapping between different endpoints
  • [x] Change param syntax from /articles/:id to /articles/{id} which improves expressiveness and delimiting (#167)
  • [x] Add support for regexp via /articles/{name:[a-z]}
  • [x] Add support for http.Handler for method routing, as in #176
  • [ ] Add a few param helpers with as chi.URLParamInt64(r, "bookID")
  • [x] Solve: Subrouters stacked, both using /{id} param key - panic? - #61

Most helpful comment

it might also be nice to support (I know others requested it) to offer a helper for building urls from named routes. Such as.

func Routes() chi.Router {
  r := chi.NewRouter()
  r.Name("articles").Route("/articles", func(r chi.Router) {
    r.Get("/", ListArticles)
    r.Route("/{id}", func(r chi.Router) {
      r.Get("/", GetArticle)
    })
  })

  articleUrlExample := r.URLFor("articles", chi.Param{"id": "1"})
  fmt.Println(articleUrlExample) // prints: /articles/1

  return r
}

All 15 comments

Add support for regexp

How about adding an option to register a "converter" https://github.com/pressly/chi/issues/167#issuecomment-293592221 and let people extend this?

Change param syntax from /articles/:id to /articles/{id} which improves expressiveness and delimiting (#167)

This one is breaking change, that's why v3.

Add support for regexp

How about adding an option to register a "converter" #167 (comment) and let people extend this?

it's indeed interesting to have types defined in the route
... but maybe we just need helpers like bookID, err := chi.URLParamInt64(r, "bookID")

How about adding a method to bind a http.handler to a specific method? For Instance:

func (mx *Mux) Handle(method string, pattern string, handler http.Handler) { mx.handle(Methods.lookup(method), pattern, handler) }
or
func (mx *Mux) Handle(method MethodTyp, pattern string, handler http.Handler) { mx.handle(method, pattern, handler) }

Hey Marcel, yep that is on the list.

it might also be nice to support (I know others requested it) to offer a helper for building urls from named routes. Such as.

func Routes() chi.Router {
  r := chi.NewRouter()
  r.Name("articles").Route("/articles", func(r chi.Router) {
    r.Get("/", ListArticles)
    r.Route("/{id}", func(r chi.Router) {
      r.Get("/", GetArticle)
    })
  })

  articleUrlExample := r.URLFor("articles", chi.Param{"id": "1"})
  fmt.Println(articleUrlExample) // prints: /articles/1

  return r
}

I haven't seen it explicitly mentioned, but...
What about support for custom HTTP methods?

Hi @pkieltyka, I would like to help with implementing something from the roadmap. Do you have any suggestions for the first contribution?

hey @tiriplicamihai thanks for the offer to help! I have been working on a PR as the base for the v3 release which resolves #167 and soon after I'll work out the mechanics for #78 and #100. These are pretty deep into the mechanics of the trie inserting / finding algorithm so its probably best I just finish that off, but certainly it would help to get reviews, write more tests - and as well, would be cool if you could write the regexp support for that branch once its ready. I will try to finish it tomorrow and ping you to look at regexp param support if you're interested.

Other work that I'd like to incorporate in the v3 release is improving chi/render further by having a full test-suite and considering the work required for #185

Sure thing. For reviews you can cc me and I will look as soon as I can.
It's ok for me to write tests (actually I think it's the best way to get an
overview), again, just ping me or assign me an issue and I'll take care of
it.

On Mon, May 22, 2017 at 2:14 AM, Peter Kieltyka notifications@github.com
wrote:

hey @tiriplicamihai https://github.com/tiriplicamihai thanks for the
offer to help! I have been working on a PR as the base for the v3 release
which resolves #167 https://github.com/pressly/chi/issues/167 and soon
after I'll work out the mechanics for #78
https://github.com/pressly/chi/issues/78 and #100
https://github.com/pressly/chi/issues/100. These are pretty deep into
the mechanics of the trie inserting / finding algorithm so its probably
best I just finish that off, but certainly it would help to get reviews,
write more tests - and as well, would be cool if you could write the regexp
support for that branch once its ready. I will try to finish it tomorrow
and ping you to look at regexp param support if you're interested.

Other work that I'd like to incorporate in the v3 release is improving
chi/render further by having a full test-suite and considering the work
required for #185 https://github.com/pressly/chi/issues/185

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/pressly/chi/issues/179#issuecomment-302969944, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABFpzJlWlqIrr7xpjkTl2eehvsIAwlIAks5r8MVKgaJpZM4M7ddo
.

--
Mihai Tiriplică

Hey everyone, I just wanted to post an update on the status of v3’s development. I have a local version that implements #78, #100, and #167 - the most challenging issues of the bunch, with all tests passing. I’m pretty excited about this release as it makes chi’s routing even more flexible with support for /articles/{month}-{day}-{year}-{slug} and /articles/{id} on the same router. Once I finish implementing regex support and confirm benchmarks are the same, I’ll push the work and tag the first v3 beta.

@pkieltyka is there anyway to achieve adding or removing routes dynamically? One good scenario would be in microservice systems. once a service is online it registers its routes to chi and during shutdown down it removes those routes.

hey @alinz - good news is Chi already supports adding routes dynamically / at runtime. Although it does not support removing routes you can either create a middleware that returns a 500 response for when the service isn't available (not online), and toggle it back when it re-registers. It's possible to solve your scenario already with chi. Let me know if you need any help thinking through your approach.

hey all, I've pushed the chi v3 branch here: https://github.com/pressly/chi/tree/v3

Its been a ton of work, but Im very happy to say it's almost finished, see checklist above for the progress. I've done some benchmarks too and the performance is the exact same as v2

v3 is complete and released! also make sure to update your import paths to github.com/go-chi/chi

02e6bbdfd14640d8c1beb15ec3a38140400fb5c2

Was this page helpful?
0 / 5 - 0 ratings

Related issues

makhov picture makhov  Â·  4Comments

Bartuz picture Bartuz  Â·  3Comments

dannyvankooten picture dannyvankooten  Â·  5Comments

kevinconway picture kevinconway  Â·  8Comments

innovate-invent picture innovate-invent  Â·  11Comments