in src/go/configinfo/service_info.go [365:415]
func (s *ServiceInfo) addHttpRule(method *MethodInfo, r *annotationspb.HttpRule, addedRouteMatchWithOptionsSet map[string]bool, disallowColonInWildcardPathSegment bool) error {
var path string
var uriTemplate *httppattern.UriTemplate
var parseError error
var httpMethod string
switch r.GetPattern().(type) {
case *annotationspb.HttpRule_Get:
path = r.GetGet()
uriTemplate, parseError = httppattern.ParseUriTemplate(path)
httpMethod = util.GET
case *annotationspb.HttpRule_Put:
path = r.GetPut()
uriTemplate, parseError = httppattern.ParseUriTemplate(path)
httpMethod = util.PUT
case *annotationspb.HttpRule_Post:
path = r.GetPost()
uriTemplate, parseError = httppattern.ParseUriTemplate(path)
httpMethod = util.POST
case *annotationspb.HttpRule_Delete:
path = r.GetDelete()
uriTemplate, parseError = httppattern.ParseUriTemplate(path)
httpMethod = util.DELETE
case *annotationspb.HttpRule_Patch:
path = r.GetPatch()
uriTemplate, parseError = httppattern.ParseUriTemplate(path)
httpMethod = util.PATCH
case *annotationspb.HttpRule_Custom:
path = r.GetCustom().GetPath()
uriTemplate, parseError = httppattern.ParseUriTemplate(path)
httpMethod = r.GetCustom().GetKind()
default:
return fmt.Errorf("error parsing http rule type for operation (%s): unsupported http method %T", method.Operation(), r.GetPattern())
}
if parseError != nil {
return fmt.Errorf("error parsing http rule address for operation (%s): %v", method.Operation(), parseError)
}
if httpMethod == util.OPTIONS {
routeMatch := uriTemplate.Regex(disallowColonInWildcardPathSegment)
addedRouteMatchWithOptionsSet[routeMatch] = true
}
httpRule := &httppattern.Pattern{
HttpMethod: httpMethod,
UriTemplate: uriTemplate,
}
method.HttpRule = append(method.HttpRule, httpRule)
return nil
}