code: func New(apiDef *raml.APIDefinition, r *raml.Resource, endpoint string, sortMethod bool) Resource {
  	name := func() string {
  		if r.DisplayName == "" {
  			return commons.NormalizeIdentifier(strings.Title(commons.NormalizeURI(endpoint)))
  		}
  		return strings.Title(commons.DisplayNameToFuncName(r.DisplayName))
  	}()
  
  	res := Resource{
  		Endpoint: endpoint,
  		APIDef:   apiDef,
  		Name:     name,
  		Resource: r,
  	}
  
  	res.generateMethods(r)
  	if sortMethod {
  		sort.Sort(byEndpoint(res.Methods))
  	}
  	return res
  }
docs: // New creates a resource definition