Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support NSRouter and multi-level namespace #587

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

jmshin92
Copy link

@jmshin92 jmshin92 commented Mar 8, 2019

  • 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() {
}

* 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`)
@astaxie astaxie requested a review from amrfaissal March 8, 2019 12:09
@zy943453722
Copy link

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

Baihhh pushed a commit to Baihhh/bee that referenced this pull request Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants