} var result <$prefix>Result if err = result.FromWire(body); err != nil { return } <if .ReturnType>success, <end>err = <$prefix>Helper.UnwrapResponse(&result) return } <end> <end> ` var templateOptions = []plugin.TemplateOption{ plugin.TemplateFunc("lower", strings.ToLower), } type generator struct{} func (generator) Generate(req *api.GenerateServiceRequest) (*api.GenerateServiceResponse, error) { files := make(map[string][]byte) for _, serviceID := range req.RootServices { service := req.Services[serviceID] module := req.Modules[service.ModuleID] var ( parent *api.Service parentModule *api.Module ) if service.ParentID != nil {
handlerPath, handlerTemplate, templateData, opts...) if err != nil { return nil, err } } return &api.GenerateServiceResponse{Files: files}, nil } // convenience function because "index .Request.Services .Service.ParentID" // doesn't work. Index expects a ServiceID, not *ServiceID. func getService(req *api.GenerateServiceRequest, id api.ServiceID) *api.Service { return req.Services[id] } var templateOptions = []plugin.TemplateOption{ plugin.TemplateFunc("basename", filepath.Base), plugin.TemplateFunc("getService", getService), } const interfaceTemplate = ` // Code generated by thriftrw --generate-plugin-api // @generated <$module := index .Request.Modules .Service.ModuleID> package <basename $module.ImportPath> type <.Service.Name> interface { <if .Service.ParentID> <$parent := getService .Request .Service.ParentID> <if eq $parent.ModuleID .Service.ModuleID> <$parent.Name>