本文整理匯總了Golang中github.com/flynn/flynn/Godeps/_workspace/src/github.com/go-martini/martini.Context.MapTo方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.MapTo方法的具體用法?Golang Context.MapTo怎麽用?Golang Context.MapTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/flynn/flynn/Godeps/_workspace/src/github.com/go-martini/martini.Context
的用法示例。
在下文中一共展示了Context.MapTo方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: validateAndMap
// Performs validation and combines errors from validation
// with errors from deserialization, then maps both the
// resulting struct and the errors to the context.
func validateAndMap(obj reflect.Value, context martini.Context, errors *Errors, ifacePtr ...interface{}) {
context.Invoke(Validate(obj.Interface()))
errors.combine(getErrors(context))
context.Map(*errors)
context.Map(obj.Elem().Interface())
if len(ifacePtr) > 0 {
context.MapTo(obj.Elem().Interface(), ifacePtr[0])
}
}
示例2: reqHelperMiddleware
func reqHelperMiddleware(c martini.Context, req *http.Request, w http.ResponseWriter, r render.Render, conf *Config) {
rh := &reqHelper{
Render: r,
ResponseWriter: w,
req: req,
conf: conf,
}
rh.session, _ = conf.SessionStore.Get(req, "session")
c.MapTo(rh, (*RequestHelper)(nil))
}
示例3: connectHostMiddleware
func connectHostMiddleware(c martini.Context, params martini.Params, cl clusterClient, r ResponseHelper) {
hostID, jobID := parseJobID(params["jobs_id"])
if hostID == "" {
log.Printf("Unable to parse hostID from %q", params["jobs_id"])
r.Error(ErrNotFound)
return
}
params["jobs_id"] = jobID
client, err := cl.DialHost(hostID)
if err != nil {
r.Error(err)
return
}
c.MapTo(client, (*cluster.Host)(nil))
c.Next()
client.Close()
}
示例4: responseHelperHandler
func responseHelperHandler(c martini.Context, w http.ResponseWriter, r render.Render) {
c.MapTo(&responseHelper{w, r}, (*ResponseHelper)(nil))
}