Documentation
¶
Index ¶
- func Vars(r *http.Request) map[string]string
- type Router
- func (rt *Router) Handle(path string, handler http.Handler)
- func (rt *Router) HandleFunc(path string, handlerFunc http.HandlerFunc)
- func (rt *Router) Methods(methods ...string) *Router
- func (rt *Router) Query(r *http.Request, key string) string
- func (rt *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (rt *Router) SetPrefix(prefix string) *Router
- func (rt *Router) SubRouter(router *Router) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router struct is router that will help to routing every incoming request. This router used tree data structure to do request routin
func (*Router) Handle ¶
Handle function is used to add handler in specific path to the router. This function take two parameters. the first parameter is path with type of string and the second paramater is handler which is a http.Handler The path that will be inserted to the router can have paremeter. To do that, the path should be written like this example : -- /home/user/{id:int} --> id is a parameter in path that just accept numeric value -- /home/{slug_name:slug} --> slug_name is a parameter in path that just accept slug You can use int, float, slug, and string in parameters Every parameter will return a string value
func (*Router) HandleFunc ¶
func (rt *Router) HandleFunc(path string, handlerFunc http.HandlerFunc)
HandleFunc function is used to add handlerfunction in specific path to the router. This function take two parameters. the first parameter is path with type of string and the second paramater is a http.handlerFunc The path that will be inserted to the router, can have paremeter. To do that, the path should be written like this example : -- /home/user/{id:int} --> id is a parameter in path that just accept numeric value -- /home/{slug_name:slug} --> slug_name is a parameter in path that just accept slug You can use int, float, slug, and string in parameters Every parameter will return a string value
func (*Router) Methods ¶
Set every http method that will assign to the path that will be added into Router object