bee icon indicating copy to clipboard operation
bee copied to clipboard

Support NSRouter and multi-level namespace

Open jmshin92 opened this issue 5 years ago • 1 comments

  • Support NSRouter
    • As NSRouter doesn't need @router annotation, changed parserComments to parse comments of HTTP method functions(Get, Post, ...) without @router annotation
  • Support multi-level namespace
    • Traverse Namespace, NSRouter, NSInclude in a depth-first manner.
    • Set controller's tag as a concatenation of route path from root(NewNamespace) to leaf nodes(NSRouter, NSInclude)
package routers

import (
	"beetest/controllers"
	"github.com/astaxie/beego"
)

func init() {
	ns := beego.NewNamespace("/v1",
		beego.NSNamespace("/object",
			beego.NSNamespace("/multi-lvl",
				beego.NSInclude(
					&controllers.ObjectController{},
				),
				beego.NSRouter("/router",
					&controllers.UserController{},
				),
			),
		),
	)
	beego.AddNamespace(ns)
}
// controllers/user.go
package controllers

import "github.com/astaxie/beego"

// Operations about Users
type UserController struct {
	beego.Controller
}

// @Title getUser
// @Description get user
// @Success 200 {string} models.User
func (o *UserController) Get() {
}

jmshin92 avatar Mar 08 '19 06:03 jmshin92

请问下这个什么时候可以合呢?

zy943453722 avatar Jul 12 '20 04:07 zy943453722