Commit 473996bd authored by lihailei's avatar lihailei

add some api interface.

parent f706afff
......@@ -9,14 +9,14 @@ import (
)
var (
chain33_jrpcIP = "http://localhost:8801"
chain33_jrpcUrl = "http://localhost:8801"
)
//func init() {
//
//}
func GetJrpcIp() string {
return chain33_jrpcIP
func SetJrpcURL(url string) {
chain33_jrpcUrl=url
}
func GetJrpcURL() string {
return chain33_jrpcUrl
}
// TODO: SetPostRunCb()
......@@ -44,40 +44,40 @@ func (c *RpcCtx) SetResultCb(cb Callback) {
c.cb = cb
}
func (c *RpcCtx) Run() {
rpc, err := jsonrpc.NewJSONClient(c.Addr)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
err = rpc.Call(c.Method, c.Params, c.Res)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
// maybe format rpc result
var result interface{}
if c.cb != nil {
result, err = c.cb(c.Res)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
} else {
result = c.Res
}
data, err := json.MarshalIndent(result, "", " ")
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
fmt.Println(string(data))
}
func (c *RpcCtx) ResponData() ([]byte, error) {
//func (c *RpcCtx) Run() {
// rpc, err := jsonrpc.NewJSONClient(c.Addr)
// if err != nil {
// fmt.Fprintln(os.Stderr, err)
// return
// }
//
// err = rpc.Call(c.Method, c.Params, c.Res)
// if err != nil {
// fmt.Fprintln(os.Stderr, err)
// return
// }
//
// // maybe format rpc result
// var result interface{}
// if c.cb != nil {
// result, err = c.cb(c.Res)
// if err != nil {
// fmt.Fprintln(os.Stderr, err)
// return
// }
// } else {
// result = c.Res
// }
//
// data, err := json.MarshalIndent(result, "", " ")
// if err != nil {
// fmt.Fprintln(os.Stderr, err)
// return
// }
//
// fmt.Println(string(data))
//}
func (c *RpcCtx) ReplyData() ([]byte, error) {
rpc, err := jsonrpc.NewJSONClient(c.Addr)
if err != nil {
fmt.Fprintln(os.Stderr, err)
......
......@@ -4,3 +4,4 @@ runmode = dev
autorender = false
copyrequestbody = false
EnableDocs = true
jrpcAddr="http://localhost:8801"
......@@ -2,6 +2,12 @@ package controllers
import (
"github.com/astaxie/beego"
jsonrpc "gitlab.33.cn/chain33/chain33/rpc"
"gitlab.33.cn/chain33/chain33/types"
. "gitlab.33.cn/lihailei/chain33_sdk/common"
. "gitlab.33.cn/lihailei/chain33_sdk/models"
"strconv"
)
// BlockController operations for Block
......@@ -11,70 +17,142 @@ type BlockController struct {
// URLMapping ...
func (c *BlockController) URLMapping() {
c.Mapping("Post", c.Post)
c.Mapping("GetOne", c.GetOne)
c.Mapping("GetAll", c.GetAll)
c.Mapping("Put", c.Put)
c.Mapping("Delete", c.Delete)
//View last block header
c.Mapping("getLastHeader", c.getLastHeader)
//Get hash of block at height
c.Mapping("getBlockHashByHeight", c.getBlockHash)
//View block info by block hash
c.Mapping("getBlockViewByHash", c.getBlockViewByHash)
//Get block headers between [start, end]
c.Mapping("getBlockHeaders", c.getBlockHeaders)
// Get block headers between [start, end]
c.Mapping("getBlockList", c.getBlockList)
}
// Post ...
// @Title Create
// @Description create Block
// @Param body body models.Block true "body for Block content"
// @Success 201 {object} models.Block
// @Failure 403 body is empty
// @router / [post]
func (c *BlockController) Post() {
//getLastHeader...
//@Title getLastHeader
//@Description getLastHeader
//@Success 200 {block}
//@Failure 403 :
//@router [get]
func (c *BlockController) getLastHeader() {
var res jsonrpc.Header
ctx := NewRpcCtx(GetJrpcURL(), "Chain33.GetLastHeader", nil, &res)
data, err := ctx.ReplyData()
if err != nil {
c.Data["json"] = err.Error()
c.ServeJSON()
} else {
c.Ctx.ResponseWriter.Write(data)
}
}
// GetOne ...
// @Title GetOne
// @Description get Block by id
// @Param id path string true "The key for staticblock"
// @Success 200 {object} models.Block
// @Failure 403 :id is empty
// @router /:id [get]
func (c *BlockController) GetOne() {
//getLastHeader...
//@Title getLastHeader
//@Description getLastHeader
//@Success 200 {block}
//@Failure 400,403:
//@router /getBlockHashByHeight [get]
func (c *BlockController) getBlockHash() {
var res jsonrpc.ReplyHash
height := c.Ctx.Request.Header.Get("height")
h, err := strconv.ParseInt(height, 10, 64)
if height == "" || err != nil {
c.Ctx.ResponseWriter.WriteHeader(400)
return
}
params := types.ReqInt{
Height: h,
}
ctx := NewRpcCtx(GetJrpcURL(), "Chain33.GetBlockHash", params, &res)
data, err := ctx.ReplyData()
if err != nil {
c.Data["json"] = err.Error()
c.ServeJSON()
} else {
c.Ctx.ResponseWriter.Write(data)
}
}
// GetAll ...
// @Title GetAll
// @Description get Block
// @Param query query string false "Filter. e.g. col1:v1,col2:v2 ..."
// @Param fields query string false "Fields returned. e.g. col1,col2 ..."
// @Param sortby query string false "Sorted-by fields. e.g. col1,col2 ..."
// @Param order query string false "Order corresponding to each sortby field, if single value, apply to all sortby fields. e.g. desc,asc ..."
// @Param limit query string false "Limit the size of result set. Must be an integer"
// @Param offset query string false "Start position of result set. Must be an integer"
// @Success 200 {object} models.Block
// @Failure 403
// @router / [get]
func (c *BlockController) GetAll() {
//getblockViewByHash...
//@Title getblockViewByHash
//@Description getblockViewByHash
//@Success 200 {blockView}
//@Failure 400,403 :
//@router /getblockViewByHash [get]
func (c *BlockController) getBlockViewByHash() {
blockHash := c.Ctx.Request.Header.Get("blockHash")
if blockHash == "" {
c.Ctx.ResponseWriter.WriteHeader(400)
return
}
params := jsonrpc.QueryParm{
Hash: blockHash,
}
var res jsonrpc.BlockOverview
ctx := NewRpcCtx(GetJrpcURL(), "Chain33.GetBlockOverview", params, &res)
data, err := ctx.ReplyData()
if err != nil {
c.Data["json"] = err.Error()
c.ServeJSON()
} else {
c.Ctx.ResponseWriter.Write(data)
}
}
// Put ...
// @Title Put
// @Description update the Block
// @Param id path string true "The id you want to update"
// @Param body body models.Block true "body for Block content"
// @Success 200 {object} models.Block
// @Failure 403 :id is not int
// @router /:id [put]
func (c *BlockController) Put() {
//getblockHeaders...
//@Title getblockHeaders
//@Description getblockHeaders
//@Success 200 {blockHeader}
//@Failure 400,403 :
//@router /getBlockHeaders [get]
func (c *BlockController) getBlockHeaders() {
startH, errS := strconv.ParseInt(c.Ctx.Request.Header.Get("startH"), 10, 64)
endH, errE := strconv.ParseInt(c.Ctx.Request.Header.Get("endH"), 10, 64)
isDetail, errD := strconv.ParseBool(c.Ctx.Request.Header.Get("detail"))
if errS != nil || errE != nil || errD != nil {
c.Ctx.ResponseWriter.WriteHeader(400)
return
}
params := types.ReqBlocks{
Start: startH,
End: endH,
Isdetail: isDetail,
}
var res jsonrpc.Headers
ctx := NewRpcCtx(GetJrpcURL(), "Chain33.GetHeaders", params, &res)
data, err := ctx.ReplyData()
if err != nil {
c.Data["json"] = err.Error()
c.ServeJSON()
} else {
c.Ctx.ResponseWriter.Write(data)
}
}
//getblockList...
//@Title getblockList
//@Description getblockList
//@Success 200 {blockList}
//@Failure 400,403 :
//@router /getBlockList [get]
func (c *BlockController) getBlockList() {
// Delete ...
// @Title Delete
// @Description delete the Block
// @Param id path string true "The id you want to delete"
// @Success 200 {string} delete success!
// @Failure 403 id is empty
// @router /:id [delete]
func (c *BlockController) Delete() {
startH, errS := strconv.ParseInt(c.Ctx.Request.Header.Get("startH"), 10, 64)
endH, errE := strconv.ParseInt(c.Ctx.Request.Header.Get("endH"), 10, 64)
isDetail, errD := strconv.ParseBool(c.Ctx.Request.Header.Get("detail"))
if errS != nil || errE != nil || errD != nil {
c.Ctx.ResponseWriter.WriteHeader(400)
return
}
params := jsonrpc.BlockParam{
Start: startH,
End: endH,
Isdetail: isDetail,
}
var res jsonrpc.BlockDetails
ctx := NewRpcCtx(GetJrpcURL(), "Chain33.GetBlocks", params, &res)
ctx.SetResultCb(ParseBlockDetail)
data, err := ctx.ReplyData()
if err != nil {
c.Data["json"] = err.Error()
c.ServeJSON()
} else {
c.Ctx.ResponseWriter.Write(data)
}
}
package controllers
import (
"encoding/json"
"gitlab.33.cn/lihailei/chain33_sdk/models"
"github.com/astaxie/beego"
)
// Operations about object
type ObjectController struct {
beego.Controller
}
// @Title Create
// @Description create object
// @Param body body models.Object true "The object content"
// @Success 200 {string} models.Object.Id
// @Failure 403 body is empty
// @router / [post]
func (o *ObjectController) Post() {
var ob models.Object
json.Unmarshal(o.Ctx.Input.RequestBody, &ob)
objectid := models.AddOne(ob)
o.Data["json"] = map[string]string{"ObjectId": objectid}
o.ServeJSON()
}
// @Title Get
// @Description find object by objectid
// @Param objectId path string true "the objectid you want to get"
// @Success 200 {object} models.Object
// @Failure 403 :objectId is empty
// @router /:objectId [get]
func (o *ObjectController) Get() {
objectId := o.Ctx.Input.Param(":objectId")
if objectId != "" {
ob, err := models.GetOne(objectId)
if err != nil {
o.Data["json"] = err.Error()
} else {
o.Data["json"] = ob
}
}
o.ServeJSON()
}
// @Title GetAll
// @Description get all objects
// @Success 200 {object} models.Object
// @Failure 403 :objectId is empty
// @router / [get]
func (o *ObjectController) GetAll() {
obs := models.GetAll()
o.Data["json"] = obs
o.ServeJSON()
}
// @Title Update
// @Description update the object
// @Param objectId path string true "The objectid you want to update"
// @Param body body models.Object true "The body"
// @Success 200 {object} models.Object
// @Failure 403 :objectId is empty
// @router /:objectId [put]
func (o *ObjectController) Put() {
objectId := o.Ctx.Input.Param(":objectId")
var ob models.Object
json.Unmarshal(o.Ctx.Input.RequestBody, &ob)
err := models.Update(objectId, ob.Score)
if err != nil {
o.Data["json"] = err.Error()
} else {
o.Data["json"] = "update success!"
}
o.ServeJSON()
}
// @Title Delete
// @Description delete the object
// @Param objectId path string true "The objectId you want to delete"
// @Success 200 {string} delete success!
// @Failure 403 objectId is empty
// @router /:objectId [delete]
func (o *ObjectController) Delete() {
objectId := o.Ctx.Input.Param(":objectId")
models.Delete(objectId)
o.Data["json"] = "delete success!"
o.ServeJSON()
}
......@@ -3,7 +3,7 @@ package controllers
import (
"github.com/astaxie/beego"
jsonrpc "gitlab.33.cn/chain33/chain33/rpc"
"gitlab.33.cn/lihailei/chain33_sdk/common"
. "gitlab.33.cn/lihailei/chain33_sdk/common"
)
// PeerController operations for Peer
......@@ -16,18 +16,16 @@ func (c *PeerController) URLMapping() {
c.Mapping("getPeers", c.GetPeers)
}
// GetOne ...
// @Title GetPeers
// @Description get Peers
// @Param id path string true "The key for staticblock"
// @Success 200 {object} models.Peer
// @Failure 403 :id is empty
// @router /:id [get]
//GetOne ...
//@Title GetPeers
//@Description get Peers
//@Success 200 {object} models.Peer
//@Failure 403 :
//@router /getPeers [get]
func (c *PeerController) GetPeers() {
rpcLaddr := common.GetJrpcIp()
var res jsonrpc.PeerList
ctx := common.NewRpcCtx(rpcLaddr, "Chain33.GetPeerInfo", nil, &res)
data, err := ctx.ResponData()
ctx := NewRpcCtx(GetJrpcURL(), "Chain33.GetPeerInfo", nil, &res)
data, err := ctx.ReplyData()
if err != nil {
c.Data["json"] = err.Error()
c.ServeJSON()
......
......@@ -2,6 +2,14 @@ package controllers
import (
"github.com/astaxie/beego"
jsonrpc "gitlab.33.cn/chain33/chain33/rpc"
. "gitlab.33.cn/lihailei/chain33_sdk/common"
. "gitlab.33.cn/lihailei/chain33_sdk/models"
"gitlab.33.cn/chain33/chain33/types"
"strconv"
"io/ioutil"
"encoding/json"
)
// TxController operations for Tx
......@@ -11,70 +19,84 @@ type TxController struct {
// URLMapping ...
func (c *TxController) URLMapping() {
c.Mapping("Post", c.Post)
c.Mapping("GetOne", c.GetOne)
c.Mapping("GetAll", c.GetAll)
c.Mapping("Put", c.Put)
c.Mapping("Delete", c.Delete)
c.Mapping("queryTxByHash", c.QueryTxByHash)
c.Mapping("queryTxByAddr", c.QueryTxByAddr)
}
// Post ...
// @Title Create
// @Description create Tx
// @Param body body models.Tx true "body for Tx content"
// @Success 201 {object} models.Tx
// @Failure 403 body is empty
// @router / [post]
func (c *TxController) Post() {
//queryTxByHash...
//@Title queryTxByHash
//@Description queryTxByHash
//@Success 200 {TX}
//@Failure 400,403 :
//@router /queryTxByHash [get]
func (c *TxController) QueryTxByHash() {
hash := c.Ctx.Request.Header.Get("hash")
isRawHex, _ := strconv.ParseBool(c.Ctx.Request.Header.Get("isRawHex"))
if hash ==""{
c.Ctx.ResponseWriter.WriteHeader(400)
return
}
var data []byte
var err error
if isRawHex {
data,err =queryByHashOutputHex(GetJrpcURL(), hash)
} else {
data,err=queryByHash(GetJrpcURL(), hash)
}
if err != nil {
c.Data["json"] = err.Error()
c.ServeJSON()
} else {
c.Ctx.ResponseWriter.Write(data)
}
}
// GetOne ...
// @Title GetOne
// @Description get Tx by id
// @Param id path string true "The key for staticblock"
// @Success 200 {object} models.Tx
// @Failure 403 :id is empty
// @router /:id [get]
func (c *TxController) GetOne() {
//queryTxByAddr...
//@Title queryTxByAddr
//@Description queryTxByAddr
//@Success 200 {TX}
//@Failure 400,403 :
//@router /queryTxByAddr [get]
func (c *TxController) QueryTxByAddr() {
var params types.ReqAddr
body,_:= ioutil.ReadAll(c.Ctx.Request.Body)
err :=json.Unmarshal(body,&params)
if err !=nil {
c.Ctx.ResponseWriter.WriteHeader(400)
return
}
//params := types.ReqAddr{
// Addr: addr,
// Flag: flag,
// Count: count,
// Direction: direction,
// Height: height,
// Index: index,
//}
var res jsonrpc.ReplyTxInfos
ctx := NewRpcCtx(GetJrpcURL(), "Chain33.GetTxByAddr", params, &res)
data, err := ctx.ReplyData()
if err != nil {
c.Data["json"] = err.Error()
c.ServeJSON()
} else {
c.Ctx.ResponseWriter.Write(data)
}
}
// GetAll ...
// @Title GetAll
// @Description get Tx
// @Param query query string false "Filter. e.g. col1:v1,col2:v2 ..."
// @Param fields query string false "Fields returned. e.g. col1,col2 ..."
// @Param sortby query string false "Sorted-by fields. e.g. col1,col2 ..."
// @Param order query string false "Order corresponding to each sortby field, if single value, apply to all sortby fields. e.g. desc,asc ..."
// @Param limit query string false "Limit the size of result set. Must be an integer"
// @Param offset query string false "Start position of result set. Must be an integer"
// @Success 200 {object} models.Tx
// @Failure 403
// @router / [get]
func (c *TxController) GetAll() {
}
// Put ...
// @Title Put
// @Description update the Tx
// @Param id path string true "The id you want to update"
// @Param body body models.Tx true "body for Tx content"
// @Success 200 {object} models.Tx
// @Failure 403 :id is not int
// @router /:id [put]
func (c *TxController) Put() {
}
// Delete ...
// @Title Delete
// @Description delete the Tx
// @Param id path string true "The id you want to delete"
// @Success 200 {string} delete success!
// @Failure 403 id is empty
// @router /:id [delete]
func (c *TxController) Delete() {
func queryByHashOutputHex(rpcAddr, txHash string)([]byte,error) {
params := jsonrpc.QueryParm{
Hash: txHash,
}
var res string
ctx := NewRpcCtx(rpcAddr, "Chain33.GetHexTxByHash", params, &res)
return ctx.ReplyData()
}
func queryByHash(rpcAddr, txHash string)([]byte,error) {
params := jsonrpc.QueryParm{
Hash: txHash,
}
var res jsonrpc.TransactionDetail
ctx := NewRpcCtx(rpcAddr, "Chain33.QueryTransaction", params, &res)
ctx.SetResultCb(ParseQueryTxRes)
return ctx.ReplyData()
}
\ No newline at end of file
package controllers
import (
"encoding/json"
"gitlab.33.cn/lihailei/chain33_sdk/models"
"github.com/astaxie/beego"
)
// Operations about Users
type UserController struct {
beego.Controller
}
// @Title CreateUser
// @Description create users
// @Param body body models.User true "body for user content"
// @Success 200 {int} models.User.Id
// @Failure 403 body is empty
// @router / [post]
func (u *UserController) Post() {
var user models.User
json.Unmarshal(u.Ctx.Input.RequestBody, &user)
uid := models.AddUser(user)
u.Data["json"] = map[string]string{"uid": uid}
u.ServeJSON()
}
// @Title GetAll
// @Description get all Users
// @Success 200 {object} models.User
// @router / [get]
func (u *UserController) GetAll() {
users := models.GetAllUsers()
u.Data["json"] = users
u.ServeJSON()
}
// @Title Get
// @Description get user by uid
// @Param uid path string true "The key for staticblock"
// @Success 200 {object} models.User
// @Failure 403 :uid is empty
// @router /:uid [get]
func (u *UserController) Get() {
uid := u.GetString(":uid")
if uid != "" {
user, err := models.GetUser(uid)
if err != nil {
u.Data["json"] = err.Error()
} else {
u.Data["json"] = user
}
}
u.ServeJSON()
}
// @Title Update
// @Description update the user
// @Param uid path string true "The uid you want to update"
// @Param body body models.User true "body for user content"
// @Success 200 {object} models.User
// @Failure 403 :uid is not int
// @router /:uid [put]
func (u *UserController) Put() {
uid := u.GetString(":uid")
if uid != "" {
var user models.User
json.Unmarshal(u.Ctx.Input.RequestBody, &user)
uu, err := models.UpdateUser(uid, &user)
if err != nil {
u.Data["json"] = err.Error()
} else {
u.Data["json"] = uu
}
}
u.ServeJSON()
}
// @Title Delete
// @Description delete the user
// @Param uid path string true "The uid you want to delete"
// @Success 200 {string} delete success!
// @Failure 403 uid is empty
// @router /:uid [delete]
func (u *UserController) Delete() {
uid := u.GetString(":uid")
models.DeleteUser(uid)
u.Data["json"] = "delete success!"
u.ServeJSON()
}
// @Title Login
// @Description Logs user into the system
// @Param username query string true "The username for login"
// @Param password query string true "The password for login"
// @Success 200 {string} login success
// @Failure 403 user not exist
// @router /login [get]
func (u *UserController) Login() {
username := u.GetString("username")
password := u.GetString("password")
if models.Login(username, password) {
u.Data["json"] = "login success"
} else {
u.Data["json"] = "user not exist"
}
u.ServeJSON()
}
// @Title logout
// @Description Logs out current logged in user session
// @Success 200 {string} logout success
// @router /logout [get]
func (u *UserController) Logout() {
u.Data["json"] = "logout success"
u.ServeJSON()
}
......@@ -4,6 +4,7 @@ import (
_ "gitlab.33.cn/lihailei/chain33_sdk/routers"
"github.com/astaxie/beego"
"gitlab.33.cn/lihailei/chain33_sdk/common"
)
func main() {
......@@ -11,5 +12,8 @@ func main() {
beego.BConfig.WebConfig.DirectoryIndex = true
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
}
if beego.AppConfig.String("jrpcAddr")!=""{
common.SetJrpcURL(beego.AppConfig.String("jrpcAddr"))
}
beego.Run()
}
package models
import (
"errors"
"strconv"
"time"
)
var (
Objects map[string]*Object
)
type Object struct {
ObjectId string
Score int64
PlayerName string
}
func init() {
Objects = make(map[string]*Object)
Objects["hjkhsbnmn123"] = &Object{"hjkhsbnmn123", 100, "astaxie"}
Objects["mjjkxsxsaa23"] = &Object{"mjjkxsxsaa23", 101, "someone"}
}
func AddOne(object Object) (ObjectId string) {
object.ObjectId = "astaxie" + strconv.FormatInt(time.Now().UnixNano(), 10)
Objects[object.ObjectId] = &object
return object.ObjectId
}
func GetOne(ObjectId string) (object *Object, err error) {
if v, ok := Objects[ObjectId]; ok {
return v, nil
}
return nil, errors.New("ObjectId Not Exist")
}
func GetAll() map[string]*Object {
return Objects
}
func Update(ObjectId string, Score int64) (err error) {
if v, ok := Objects[ObjectId]; ok {
v.Score = Score
return nil
}
return errors.New("ObjectId Not Exist")
}
func Delete(ObjectId string) {
delete(Objects, ObjectId)
}
package models
import (
"errors"
"strconv"
"time"
)
var (
UserList map[string]*User
)
func init() {
UserList = make(map[string]*User)
u := User{"user_11111", "astaxie", "11111", Profile{"male", 20, "Singapore", "astaxie@gmail.com"}}
UserList["user_11111"] = &u
}
type User struct {
Id string
Username string
Password string
Profile Profile
}
type Profile struct {
Gender string
Age int
Address string
Email string
}
func AddUser(u User) string {
u.Id = "user_" + strconv.FormatInt(time.Now().UnixNano(), 10)
UserList[u.Id] = &u
return u.Id
}
func GetUser(uid string) (u *User, err error) {
if u, ok := UserList[uid]; ok {
return u, nil
}
return nil, errors.New("User not exists")
}
func GetAllUsers() map[string]*User {
return UserList
}
func UpdateUser(uid string, uu *User) (a *User, err error) {
if u, ok := UserList[uid]; ok {
if uu.Username != "" {
u.Username = uu.Username
}
if uu.Password != "" {
u.Password = uu.Password
}
if uu.Profile.Age != 0 {
u.Profile.Age = uu.Profile.Age
}
if uu.Profile.Address != "" {
u.Profile.Address = uu.Profile.Address
}
if uu.Profile.Gender != "" {
u.Profile.Gender = uu.Profile.Gender
}
if uu.Profile.Email != "" {
u.Profile.Email = uu.Profile.Email
}
return u, nil
}
return nil, errors.New("User Not Exist")
}
func Login(username, password string) bool {
for _, u := range UserList {
if u.Username == username && u.Password == password {
return true
}
}
return false
}
func DeleteUser(uid string) {
delete(UserList, uid)
}
This diff is collapsed.
......@@ -16,16 +16,6 @@ import (
func init() {
ns := beego.NewNamespace("/v1",
beego.NSNamespace("/object",
beego.NSInclude(
&controllers.ObjectController{},
),
),
beego.NSNamespace("/user",
beego.NSInclude(
&controllers.UserController{},
),
),
beego.NSNamespace("/peer",
beego.NSInclude(
&controllers.PeerController{},
......@@ -50,4 +40,7 @@ func init() {
ctx.Request.Header.Set("privateKey", "CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944")
})
beego.AddNamespace(ns)
//beego.Router("/v1/peer",&controllers.PeerController{},)
//beego.Router("/v1/block",&controllers.BlockController{})
//beego.Router("/v1/tx",&controllers.TxController{})
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment