binding.go
func Bind(obj interface{}, ifacePtr ...interface{}) martini.Handler {
	return func(context martini.Context, req *http.Request) {
		contentType := req.Header.Get("Content-Type")

		if req.Method == "POST" || req.Method == "PUT" || req.Method == "PATCH" || contentType != "" {
			if strings.Contains(contentType, "form-urlencoded") {
				context.Invoke(Form(obj, ifacePtr...))
			} else if strings.Contains(contentType, "multipart/form-data") {
				context.Invoke(MultipartForm(obj, ifacePtr...))
			} else if strings.Contains(contentType, "json") {
				context.Invoke(Json(obj, ifacePtr...))
			} else {
				var errors Errors
				if contentType == "" {
					errors.Add([]string{}, ContentTypeError, "Empty Content-Type")
				} else {
					errors.Add([]string{}, ContentTypeError, "Unsupported Content-Type")
				}
				context.Map(errors)
			}
		} else {
			context.Invoke(Form(obj, ifacePtr...))
		}

		context.Invoke(ErrorHandler)
	}
}
func Bind(obj interface{}, ifacePtr ...interface{}) martini.Handler {
	return func(context martini.Context, req *http.Request) {
		contentType := req.Header.Get("Content-Type")

		if req.Method == "POST" || req.Method == "PUT" || req.Method == "PATCH" || contentType != "" {
			if strings.Contains(contentType, "form-urlencoded") {
				context.Invoke(Form(obj, ifacePtr...))
			} else if strings.Contains(contentType, "multipart/form-data") {
				context.Invoke(MultipartForm(obj, ifacePtr...))
			} else if strings.Contains(contentType, "json") {
				context.Invoke(Json(obj, ifacePtr...))
			} else {
				var errors Errors
				if contentType == "" {
					errors.Add([]string{}, ContentTypeError, "Empty Content-Type")
				} else {
					errors.Add([]string{}, ContentTypeError, "Unsupported Content-Type")
				}
				context.Map(errors)
			}
		} else {
			context.Invoke(Form(obj, ifacePtr...))
		}

		context.Invoke(ErrorHandler)
	}
}
func Bind ( obj interface { } , ifacePtr ... interface { } ) martini . Handler { return func ( context martini . Context , req * http . Request ) { contentType := req . Header . Get ( " " ) if req . Method == " " || req . Method == " " || req . Method == " " || contentType != " " { if strings . Contains ( contentType , " " ) { context . Invoke ( Form ( obj , ifacePtr ... ) ) } else if strings . Contains ( contentType , " " ) { context . Invoke ( MultipartForm ( obj , ifacePtr ... ) ) } else if strings . Contains ( contentType , " " ) { context . Invoke ( Json ( obj , ifacePtr ... ) ) } else { var errors Errors if contentType == " " { errors . Add ( [ ] string { } , ContentTypeError , " " ) } else { errors . Add ( [ ] string { } , ContentTypeError , " " ) } context . Map ( errors ) } } else { context . Invoke ( Form ( obj , ifacePtr ... ) ) } context . Invoke ( ErrorHandler ) } }
/*
	For the land of Middle-ware Earth:
		One func to rule them all,
		One func to find them,
		One func to bring them all,
		And in this package BIND them.
*/
// Bind wraps up the functionality of the Form and Json middleware
// according to the Content-Type and verb of the request.
// A Content-Type is required for POST, PUT and PATCH requests.
// Bind invokes the ErrorHandler middleware to bail out if errors
// occurred. If you want to perform your own error handling, use
// Form or Json middleware directly. An interface pointer can
// be added as a second argument in order to map the struct to
// a specific interface.
/ * For the land of Middle - ware Earth : One func to rule them all One func to find them One func to bring them all And in this package BIND them . Bind wraps up the functionality of the Form and Json middleware according to the Content - Type and verb of the request . A Content - Type is required for POST PUT and PATCH requests . Bind invokes the ErrorHandler middleware to bail out if errors occurred . If you want to perform your own error handling use Form or Json middleware directly . An interface pointer can be added as a second argument in order to map the struct to a specific interface .