// MountAccountController "mounts" a Account resource controller on the given service. func MountAccountController(service goa.Service, ctrl AccountController) { // Setup encoders and decoders. This is idempotent and is done by each MountXXX function. tmp15 := goa.GobEncoderFactory() service.SetEncoder(tmp15, false, "application/gob", "application/x-gob") tmp16 := goa.JSONEncoderFactory() service.SetEncoder(tmp16, true, "application/json") tmp17 := goa.XMLEncoderFactory() service.SetEncoder(tmp17, false, "application/xml", "text/xml") tmp18 := goa.GobDecoderFactory() service.SetDecoder(tmp18, false, "application/gob", "application/x-gob") tmp19 := goa.JSONDecoderFactory() service.SetDecoder(tmp19, true, "application/json") tmp20 := goa.XMLDecoderFactory() service.SetDecoder(tmp20, false, "application/xml", "text/xml") // Setup endpoint handler var h goa.Handler mux := service.ServeMux() h = func(c *goa.Context) error { ctx, err := NewCreateAccountContext(c) ctx.Payload = ctx.RawPayload().(*CreateAccountPayload) if err != nil { return goa.NewBadRequestError(err) } return ctrl.Create(ctx) } mux.Handle("POST", "/cellar/accounts", ctrl.HandleFunc("Create", h, unmarshalCreateAccountPayload)) service.Info("mount", "ctrl", "Account", "action", "Create", "route", "POST /cellar/accounts") h = func(c *goa.Context) error { ctx, err := NewDeleteAccountContext(c) if err != nil { return goa.NewBadRequestError(err) } return ctrl.Delete(ctx) } mux.Handle("DELETE", "/cellar/accounts/:accountID", ctrl.HandleFunc("Delete", h, nil)) service.Info("mount", "ctrl", "Account", "action", "Delete", "route", "DELETE /cellar/accounts/:accountID") h = func(c *goa.Context) error { ctx, err := NewShowAccountContext(c) if err != nil { return goa.NewBadRequestError(err) } return ctrl.Show(ctx) } mux.Handle("GET", "/cellar/accounts/:accountID", ctrl.HandleFunc("Show", h, nil)) service.Info("mount", "ctrl", "Account", "action", "Show", "route", "GET /cellar/accounts/:accountID") h = func(c *goa.Context) error { ctx, err := NewUpdateAccountContext(c) ctx.Payload = ctx.RawPayload().(*UpdateAccountPayload) if err != nil { return goa.NewBadRequestError(err) } return ctrl.Update(ctx) } mux.Handle("PUT", "/cellar/accounts/:accountID", ctrl.HandleFunc("Update", h, unmarshalUpdateAccountPayload)) service.Info("mount", "ctrl", "Account", "action", "Update", "route", "PUT /cellar/accounts/:accountID") }
// MountBottleController "mounts" a Bottle resource controller on the given service. func MountBottleController(service goa.Service, ctrl BottleController) { // Setup encoders and decoders. This is idempotent and is done by each MountXXX function. tmp21 := goa.GobEncoderFactory() service.SetEncoder(tmp21, false, "application/gob", "application/x-gob") tmp22 := goa.JSONEncoderFactory() service.SetEncoder(tmp22, true, "application/json") tmp23 := goa.XMLEncoderFactory() service.SetEncoder(tmp23, false, "application/xml", "text/xml") tmp24 := goa.GobDecoderFactory() service.SetDecoder(tmp24, false, "application/gob", "application/x-gob") tmp25 := goa.JSONDecoderFactory() service.SetDecoder(tmp25, true, "application/json") tmp26 := goa.XMLDecoderFactory() service.SetDecoder(tmp26, false, "application/xml", "text/xml") // Setup endpoint handler var h goa.Handler mux := service.ServeMux() h = func(c *goa.Context) error { ctx, err := NewCreateBottleContext(c) ctx.Payload = ctx.RawPayload().(*CreateBottlePayload) if err != nil { return goa.NewBadRequestError(err) } return ctrl.Create(ctx) } mux.Handle("POST", "/cellar/accounts/:accountID/bottles", ctrl.HandleFunc("Create", h, unmarshalCreateBottlePayload)) service.Info("mount", "ctrl", "Bottle", "action", "Create", "route", "POST /cellar/accounts/:accountID/bottles") h = func(c *goa.Context) error { ctx, err := NewDeleteBottleContext(c) if err != nil { return goa.NewBadRequestError(err) } return ctrl.Delete(ctx) } mux.Handle("DELETE", "/cellar/accounts/:accountID/bottles/:bottleID", ctrl.HandleFunc("Delete", h, nil)) service.Info("mount", "ctrl", "Bottle", "action", "Delete", "route", "DELETE /cellar/accounts/:accountID/bottles/:bottleID") h = func(c *goa.Context) error { ctx, err := NewListBottleContext(c) if err != nil { return goa.NewBadRequestError(err) } return ctrl.List(ctx) } mux.Handle("GET", "/cellar/accounts/:accountID/bottles", ctrl.HandleFunc("List", h, nil)) service.Info("mount", "ctrl", "Bottle", "action", "List", "route", "GET /cellar/accounts/:accountID/bottles") h = func(c *goa.Context) error { ctx, err := NewRateBottleContext(c) ctx.Payload = ctx.RawPayload().(*RateBottlePayload) if err != nil { return goa.NewBadRequestError(err) } return ctrl.Rate(ctx) } mux.Handle("PUT", "/cellar/accounts/:accountID/bottles/:bottleID/actions/rate", ctrl.HandleFunc("Rate", h, unmarshalRateBottlePayload)) service.Info("mount", "ctrl", "Bottle", "action", "Rate", "route", "PUT /cellar/accounts/:accountID/bottles/:bottleID/actions/rate") h = func(c *goa.Context) error { ctx, err := NewShowBottleContext(c) if err != nil { return goa.NewBadRequestError(err) } return ctrl.Show(ctx) } mux.Handle("GET", "/cellar/accounts/:accountID/bottles/:bottleID", ctrl.HandleFunc("Show", h, nil)) service.Info("mount", "ctrl", "Bottle", "action", "Show", "route", "GET /cellar/accounts/:accountID/bottles/:bottleID") h = func(c *goa.Context) error { ctx, err := NewUpdateBottleContext(c) ctx.Payload = ctx.RawPayload().(*UpdateBottlePayload) if err != nil { return goa.NewBadRequestError(err) } return ctrl.Update(ctx) } mux.Handle("PATCH", "/cellar/accounts/:accountID/bottles/:bottleID", ctrl.HandleFunc("Update", h, unmarshalUpdateBottlePayload)) service.Info("mount", "ctrl", "Bottle", "action", "Update", "route", "PATCH /cellar/accounts/:accountID/bottles/:bottleID") }