MCPcopy
hub / github.com/cortesi/devd / newRoute

Function newRoute

route.go:97–114  ·  view source on GitHub ↗

Constructs a new route from a string specifcation. Specifcations are of the form ANCHOR=VALUE.

(s string, notfound []string)

Source from the content-addressed store, hash-verified

95// Constructs a new route from a string specifcation. Specifcations are of the
96// form ANCHOR=VALUE.
97func newRoute(s string, notfound []string) (*Route, error) {
98 rp, err := routespec.ParseRouteSpec(s)
99 if err != nil {
100 return nil, err
101 }
102
103 var ep endpoint
104
105 if rp.IsURL {
106 ep, err = newForwardEndpoint(rp.Value)
107 } else {
108 ep, err = newFilesystemEndpoint(rp.Value, notfound)
109 }
110 if err != nil {
111 return nil, err
112 }
113 return &Route{rp.Host, rp.Path, ep}, nil
114}
115
116// MuxMatch produces a match clause suitable for passing to a Mux
117func (f Route) MuxMatch() string {

Callers 4

TestParseSpecFunction · 0.85
TestNewRouteFunction · 0.85
TestRouteHandlerFunction · 0.85
AddMethod · 0.85

Calls 2

newForwardEndpointFunction · 0.85
newFilesystemEndpointFunction · 0.85

Tested by 3

TestParseSpecFunction · 0.68
TestNewRouteFunction · 0.68
TestRouteHandlerFunction · 0.68