go-ozzo / ozzo-routing

An extremely fast Go (golang) HTTP router that supports regular expression route matching. Comes with full support for building RESTful APIs.
MIT License
455 stars 51 forks source link

Exposing Find #46

Closed jackwhelpton closed 6 years ago

jackwhelpton commented 6 years ago

I raised a ticket to discuss this proposal about a month ago:

https://github.com/go-ozzo/ozzo-routing/issues/42

The change is very slight, just exposing the Find method on the router. The purpose of this is to allow an API to map an internal or "self" link to a database entity, by determining the ID of the object that link represents.

I've also moved the Find method up in its file to keep all the public methods together.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 94.034% when pulling b189791610c5163f0e14e4b5d91e245e28656d79 on jackwhelpton:master into efb54ad73e4e1e1bac695b8017a4ddde7220ab0d on go-ozzo:master.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 94.034% when pulling b189791610c5163f0e14e4b5d91e245e28656d79 on jackwhelpton:master into efb54ad73e4e1e1bac695b8017a4ddde7220ab0d on go-ozzo:master.

qiangxue commented 6 years ago

Instead of directly exposing find, I think we should wrap it with a new public method to have a more meaningful function signature, something like this

Find(method, path string) (handlers []Handler, params map[string]string)
coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.06%) to 94.095% when pulling 44ec0bcc256c40771716d44c865ce37f0bb8868b on jackwhelpton:master into efb54ad73e4e1e1bac695b8017a4ddde7220ab0d on go-ozzo:master.

jackwhelpton commented 6 years ago

That makes a lot of sense; I've done that in the latest commit. Let me know if there are any other changes you'd like to see.

As a follow-up question, I'm actually working with the fasthttp-routing adaptation of ozzo-routing, so I'd like to get this change over to there too. I could make a separate PR to re-implement this small change, but I wonder if it might make more sense to make a fresh fork of ozzo-routing and re-introduce the fasthttp changes there, as the current fasthttp-routing looks to be several years behind what's here?

I can fork ozzo again into my personal Github and just make those changes there (i.e. github.com/jackwhelpton/fasthttp-routing), but would you have a preferred method for updating the current version?

qiangxue commented 6 years ago

Thanks!

Regarding fasthttp-routing, yes it's outdated (far behind from both ozzo-routing and fasthttp). So it makes sense to fork from the latest ozzo-routing and incorporates the latest fasthttp. I think it makes sense to keep it under your personal github.