Added mass register funcs and example used as test. - #1
Conversation
sqp
commented
Aug 11, 2017
- The router type now just extends the mux.Router so we can use it directly (and get the returned object from HandleFunc to add more options).
- RegisterGet and RegisterPost are used to add lists of routes (see example).
- The example shows how to register handlers and 2 of its 3 paths are used in the test (need POST).
- The router type now just extends the mux.Router so we can use it directly (and get the returned object from HandleFunc to add more options). - RegisterGet and RegisterPost are used to add lists of routes (see example). - The example shows how to register handlers and 2 of its 3 paths are used in the test (need POST).
|
@sqp - this looks great, and I like how you designed the RegisterGet/Post methods to make a more straightforward API, but I have a couple comments. Also, I had initially decided not to embed the *mux.Router so that it would be easy to swap it out for another if that was something we wanted to do later, while still making it accessible outside the package. If you think it is definitely better off embedded, please share! I think the frontend.RegisterGet(frontend.ListHandle{{
URL: "/",
Handler: viewHomePage,
}, {
URL: "/other/{keyName}",
Handler: viewOther,
}}.ToHandlers()...)when it's possible to do something like: frontend.RegisterGet(frontend.Route{
"/": viewHomePage,
"/other/{keyName}": viewOther,
})I think keeping the new syntax to a minimum helps a lot to improve usability... what do you think? |