func canModifyGWallet(hr *HtmlReq) bool { glog.Infoln(hr.Role.Type == models.RoleF, hr.Rec.Status == models.C*K, (hr.Type == models.Deposit || hr.Type == models.Issue)) if hr.Role.Type == models.RoleF && hr.Rec.Status == models.C*K && (hr.Type == models.Deposit || hr.Type == models.Issue) { return true } glog.Infoln("go here") return false }
func main() { glog.SetLogDirs(".") glog.SetLogToStderr(true) conf := controllers.Gconf beego.Get("/federation", func(ctx *context.Context) { federation(ctx, conf) }) beego.Get("/ripple.txt", func(ctx *context.Context) { f, err := os.Open("ripple.txt") if err != nil { glog.Fatal(err) } io.Copy(ctx.ResponseWriter, f) f.Close() }) beego.Get("/quote", func(ctx *context.Context) { u := "http://" + conf.Host + "/api/quote?" + ctx.Request.URL.RawQuery glog.Infoln(u) r, err := http.Get(u) if err != nil { glog.Errorln(err) return } io.Copy(ctx.ResponseWriter, r.Body) r.Body.Close() }) beego.Run() }
func getHoltWallets() []string { hws := make([]string, len(models.Gconf.HoltWallet)) for i, x := range models.Gconf.HoltWallet { hws[i] = x.Name + ":" + x.AccountId } glog.Infoln(hws) return hws }
// NewRemote returns a new remote session connected to the specified // server endpoint URI. To close the connection, use Close(). func NewRemote(endpoint string) (*Remote, error) { glog.Infoln(endpoint) dialer := &websocket.Dialer{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}} ws, _, err := dialer.Dial(endpoint, nil) //NewClient(c, u, nil, 1024, 1024) if err != nil { return nil, err } r := &Remote{ Incoming: make(chan interface{}, 10), outgoing: make(chan Syncer, 10), ws: ws, } go r.run() return r, nil }
func (c *MainController) Deposit() { r := c.Ctx.Request u := *r.URL u.Scheme = "http" u.Host = Gconf.Host u.Path = "/api" + u.Path glog.Infoln(u) var resp *http.Response var err error if r.Method == "GET" { resp, err = http.Get(u.String()) } else { contentType := r.Header.Get("Content-Type") var nr *http.Request if strings.Contains(contentType, "multipart/form-data") { buf := &bytes.Buffer{} writer := multipart.NewWriter(buf) i := strings.Index(contentType, "--") boundary := contentType[i:] err = writer.SetBoundary(boundary) if err != nil { glog.Infoln(err) return } for k, v := range r.MultipartForm.Value { writer.WriteField(k, v[0]) } for k, v := range r.MultipartForm.File { w, err := writer.CreateFormFile(k, v[0].Filename) if err != nil { glog.Errorln(err) return } f, err := v[0].Open() if err != nil { glog.Errorln(err) return } io.Copy(w, f) f.Close() } writer.Close() nr, err = http.NewRequest(r.Method, u.String(), buf) } else { nr, err = http.NewRequest(r.Method, u.String(), strings.NewReader(r.Form.Encode())) } if err != nil { glog.Errorln(err) return } nr.Header.Set("Content-Type", contentType) resp, err = http.DefaultClient.Do(nr) } if err != nil { glog.Errorln(err) c.Redirect("/", 302) return } io.Copy(c.Ctx.ResponseWriter, resp.Body) }