beego

Beego and Https

寵の児 提交于 2019-12-13 08:46:21
问题 Tried to set up https, as described here: https://github.com/astaxie/beego/issues/401 and got this in the logs: 2016/09/28 14:05:34 [I] [asm_amd64.s:2086] https server Running on https://127.0.0.1:10443 2016/09/28 14:05:37 [server.go:2315] [HTTP] http: TLS handshake error from 127.0.0.1:65365: tls: first record does not look like a TLS handshake I am running it on Windows 10. Any one got Beego working with https? I used self signed certificate, which works fine for generic golang https simple

Insert for model with m2m in beego orm

℡╲_俬逩灬. 提交于 2019-12-11 06:36:49
问题 I have two models: type MainFields struct { Id int `orm:"auto"` Created time.Time `orm:"auto_now_add;type(datetime)"` Updated time.Time `orm:"auto_now;type(datetime)"` } type Game struct { MainFields Players []*Player `orm:"rel(m2m)"` } type Player struct { MainFields Games []*Game `orm:"reverse(many)"` NickName string } And with this code i`am trying to create new game with one player: func insertTestData() { var playerA models.Player playerA.NickName = "CoolDude" id, err := models.ORM

Beego must have one register DataBase alias named `default`

亡梦爱人 提交于 2019-12-11 05:42:39
问题 In the production server with Beego I get must have one register DataBase alias named default I know the db connection credentials work in the server but whenever I do restful request I get this error and the Beego server crashes. Is there a reason why this is happening? Below is the code inside main.go init function: orm.RegisterDriver("postgres", orm.DR_Postgres) orm.RegisterDataBase("default", "postgres", fmt.Sprintf("postgres://%s:%s@%s/%s?port=%i", pgUser, pgPass, pgHost, pgDb, pgPort))

Beego Test Case returns 404 status, endpoint not match

泪湿孤枕 提交于 2019-12-11 05:27:09
问题 Below is my test case where I am checking one of my API endpoints. package test import ( "net/http" "net/http/httptest" "path/filepath" "runtime" "testing" "github.com/astaxie/beego" . "github.com/smartystreets/goconvey/convey" ) func init() { _, file, _, _ := runtime.Caller(1) apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator)))) beego.TestBeegoInit(apppath) } // TestGet is a sample to run an endpoint test func TestGet(t *testing.T) { r, _ := http

get image and upload/save it in server location

梦想的初衷 提交于 2019-12-11 01:59:29
问题 I have an beego application in which i have a requirement of uploading a image from client for to server location. //Till now I have tried the following script $("#fileupload").on("click",function(){ $("#my_file").click(); userImage = document.getElementById('fileupload'); imgData = getBase64Image(userImage); localStorage.setItem("imgData", imgData); }); <!--Html where i have kept option for image upload--> <ul> <li style="margin-top:5px;"> .Hii vijay </li> <li><input type="file" id="my_file"

Beego - Endpoint Testing

痴心易碎 提交于 2019-12-10 18:09:15
问题 I am testing http custom endpoint for beego package test import ( "github.com/astaxie/beego" . "github.com/smartystreets/goconvey/convey" _ "golife-api-cons/routers" "net/http" "net/http/httptest" "path/filepath" "runtime" "testing" ) func init() { _, file, _, _ := runtime.Caller(1) apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator)))) beego.TestBeegoInit(apppath) } // TestGet is a sample to run an endpoint test func TestGet(t *testing.T) { r, _ :=

POST request treated as OPTIONS on beego framework

北慕城南 提交于 2019-12-07 11:19:20
问题 I'm using beego framework as my API framework and AngularJS on the client. I have set all CORS setting correctly. I can do GET request. But, when i try to POST, beego treat is as OPTIONS request. It also throw a warning: multiple response.WriteHeader calls . what could possibly wrong? my beego CORS setting: func init() { orm.RegisterDataBase("default", "mysql", "root:@tcp(127.0.0.1:3306)/fakeapi") beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{ AllowOrigins: []string{"*"

POST request treated as OPTIONS on beego framework

◇◆丶佛笑我妖孽 提交于 2019-12-05 18:01:34
I'm using beego framework as my API framework and AngularJS on the client. I have set all CORS setting correctly. I can do GET request. But, when i try to POST, beego treat is as OPTIONS request. It also throw a warning: multiple response.WriteHeader calls . what could possibly wrong? my beego CORS setting: func init() { orm.RegisterDataBase("default", "mysql", "root:@tcp(127.0.0.1:3306)/fakeapi") beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{ AllowOrigins: []string{"*"}, AllowMethods: []string{"GET", "DELETE", "PUT", "PATCH", "POST"}, AllowHeaders: []string{"Origin"},

beego和bee安装问题解决

夙愿已清 提交于 2019-12-05 15:19:14
如果使用go mod模式,直接安装bee时会报错: go: github.com/beego/bee imports github.com/beego/bee/cmd imports github.com/beego/bee/cmd/commands/dlv imports github.com/derekparker/delve/service: github.com/derekparker/delve@v1.3.1: parsing go.mod: module declares its path as: github.com/go-delve/delve but was required as: github.com/derekparker/delve 主要参考URL: http://www.678fly.cn/d/3-go-mod-bee 一、创建一个 go mod 下的文件夹 mkdir test cd test go mod init test 二、在 go.mod 内把 bee 的源替换掉,如下所示: github.com/realguan/bee 是我 fork 了 github.com/beego/bee 的源码,进行了源代码更改: module test replace github.com/beego/bee v1.10.0 => github.com

beego 打包部署

强颜欢笑 提交于 2019-12-05 08:23:05
一. 打包 1. 打开Terminal 定位到工程的 main.go 文件夹目录 2. 执行命令,打包   linux打包: bee pack -be GOOS=linux   windows打包: bee pack -be GOOS=windows 二. 部署 来源: https://www.cnblogs.com/ITPower/p/11915232.html