MCPcopy Index your code
hub / github.com/labstack/echo / setPathValues

Method setPathValues

context.go:319–334  ·  view source on GitHub ↗
(pv *PathValues)

Source from the content-addressed store, hash-verified

317}
318
319func (c *Context) setPathValues(pv *PathValues) {
320 // Router accesses c.pathValues by index and may resize it to full capacity during routing
321 // for that to work without going out-of-bounds we must make sure that c.pathValues slice is not replaced with smaller
322 // slice than Router can set when routing Route with maximum amount of parameters.
323 pathValues := c.pathValues
324 if cap(*c.pathValues) < len(*pv) {
325 // normally we should not end up here. pathValues is normally sized to Echo.contextPathParamAllocSize which should not
326 // be smaller than anything router knows as maximum path parameter count to be.
327 tmp := make(PathValues, len(*pv))
328 c.pathValues = &tmp
329 pathValues = c.pathValues
330 } else if len(*c.pathValues) != len(*pv) {
331 *pathValues = (*pathValues)[0:len(*pv)] // resize slice to given params length for copy to work
332 }
333 copy(*pathValues, *pv)
334}
335
336// QueryParam returns the query param for the provided name.
337func (c *Context) QueryParam(name string) string {

Callers 2

SetPathValuesMethod · 0.95
InitializeRouteMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected