MCPcopy Create free account
hub / github.com/BryanMwangi/pine / Insert

Method Insert

router.go:30–39  ·  view source on GitHub ↗

Insert registers handlers for a given HTTP method and path. Segments starting with ':' are treated as named parameters. A trailing '/*' is treated as a catch-all wildcard.

(method, path string, handlers []Handler)

Source from the content-addressed store, hash-verified

28// Segments starting with ':' are treated as named parameters.
29// A trailing '/*' is treated as a catch-all wildcard.
30func (r *Router) Insert(method, path string, handlers []Handler) {
31 if path == "" {
32 path = "/"
33 }
34 // Trim leading slash so we work with the suffix only.
35 if path[0] == '/' {
36 path = path[1:]
37 }
38 r.root.insert(method, path, handlers, nil)
39}
40
41// Search finds the handlers registered for method+path.
42// Returns (handlers, params, found).

Callers 10

insertRouteFunction · 0.80
TestRouter_SingleParamFunction · 0.80
TestRouter_DeepNestingFunction · 0.80
TestRouter_WildcardFunction · 0.80
TestRouter_ManyRoutesFunction · 0.80
BenchmarkRouter_InsertFunction · 0.80
AddRouteMethod · 0.80
UseMethod · 0.80

Calls 1

insertMethod · 0.80

Tested by 8

insertRouteFunction · 0.64
TestRouter_SingleParamFunction · 0.64
TestRouter_DeepNestingFunction · 0.64
TestRouter_WildcardFunction · 0.64
TestRouter_ManyRoutesFunction · 0.64
BenchmarkRouter_InsertFunction · 0.64