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

Method AddRoute

pine.go:288–304  ·  view source on GitHub ↗

AddRoute registers a route for the given method and path.

(method, path string, handlers ...Handler)

Source from the content-addressed store, hash-verified

286
287// AddRoute registers a route for the given method and path.
288func (server *Server) AddRoute(method, path string, handlers ...Handler) {
289 server.mutex.Lock()
290 defer server.mutex.Unlock()
291
292 if !isValidMethod(method) {
293 server.errorLog.Printf("Invalid HTTP method: %s", method)
294 return
295 }
296
297 route := &Route{
298 Method: method,
299 Path: path,
300 Handlers: handlers,
301 }
302 server.routes = append(server.routes, route)
303 server.router.Insert(method, path, server.wrapHandlers(handlers))
304}
305
306func (server *Server) Get(path string, handlers ...Handler) {
307 server.AddRoute(MethodGet, path, handlers...)

Callers 6

GetMethod · 0.95
PostMethod · 0.95
PutMethod · 0.95
PatchMethod · 0.95
DeleteMethod · 0.95
OptionsMethod · 0.95

Calls 3

wrapHandlersMethod · 0.95
isValidMethodFunction · 0.85
InsertMethod · 0.80

Tested by

no test coverage detected