コード例 #1
0
ファイル: method.go プロジェクト: robvanmieghem/go-raml
func newMethod(r *raml.Resource, rd *resourceDef, m *raml.Method, methodName string) method {
	method := method{
		Method:   m,
		Endpoint: r.FullURI(),
		verb:     strings.ToUpper(methodName),
		resource: r,
	}

	// set request body
	method.ReqBody = setBodyName(m.Bodies, normalizeURITitle(method.Endpoint)+methodName, reqBodySuffix)

	//set response body
	for k, v := range m.Responses {
		if k >= 200 && k < 300 {
			method.RespBody = setBodyName(v.Bodies, normalizeURITitle(method.Endpoint)+methodName, respBodySuffix)
		}
	}

	// set func comment
	if len(m.Description) > 0 {
		method.FuncComments = commentBuilder(m.Description)
	}

	return method
}
コード例 #2
0
ファイル: method.go プロジェクト: Jumpscale/go-raml
func NewMethod(r *raml.Resource, rd *Resource, m *raml.Method, methodName string, sbn SetBodyName) Method {
	method := Method{
		Method:       m,
		Endpoint:     r.FullURI(),
		verb:         strings.ToUpper(methodName),
		RAMLResource: r,
	}

	// set request body
	method.ReqBody = sbn(m.Bodies, method.Endpoint+methodName, commons.ReqBodySuffix)

	//set response body
	for k, v := range m.Responses {
		code := commons.AtoiOrPanic(string(k))
		if code >= 200 && code < 300 {
			method.RespBody = sbn(v.Bodies, method.Endpoint+methodName, commons.RespBodySuffix)
		}
	}

	// set func comment
	if len(m.Description) > 0 {
		method.FuncComments = commons.ParseDescription(m.Description)
	}

	return method
}
コード例 #3
0
ファイル: method.go プロジェクト: Jumpscale/go-raml
func newMethod(r *raml.Resource, rd *cr.Resource, m *raml.Method,
	methodName string) (cr.MethodInterface, error) {

	rm := cr.NewMethod(r, rd, m, methodName, setBodyName)

	// set method name
	if len(rm.DisplayName) > 0 {
		rm.MethodName = strings.Replace(rm.DisplayName, " ", "", -1)
	} else {
		rm.MethodName = commons.NormalizeURI(formatProcName(r.FullURI())) + methodName
	}
	rm.ResourcePath = commons.ParamizingURI(rm.Endpoint, "&")
	return method{Method: &rm}, nil
}