41 lines
		
	
	
		
			755 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			755 B
		
	
	
	
		
			Go
		
	
	
	
	
	
// Package router ...
 | 
						|
//
 | 
						|
// Description : router ...
 | 
						|
//
 | 
						|
// Author : go_developer@163.com<白茶清欢>
 | 
						|
//
 | 
						|
// Date : 2025-05-28 20:58
 | 
						|
package router
 | 
						|
 | 
						|
import (
 | 
						|
	"testing"
 | 
						|
 | 
						|
	"github.com/gin-gonic/gin"
 | 
						|
)
 | 
						|
 | 
						|
type testCommon struct {
 | 
						|
	UserID uint `json:"user_id"`
 | 
						|
}
 | 
						|
 | 
						|
type testForm struct {
 | 
						|
	Meta `json:"-" method:"get" path:"test"`
 | 
						|
	testCommon
 | 
						|
	Name string `json:"name"`
 | 
						|
}
 | 
						|
 | 
						|
func TestNewServer(t *testing.T) {
 | 
						|
	s := NewServer(9087)
 | 
						|
	s.AddCommonParamRule("UserID", func(ctx *gin.Context) (any, error) {
 | 
						|
		return uint(123456), nil
 | 
						|
	})
 | 
						|
	s.Group("", nil, testController{})
 | 
						|
	s.Start()
 | 
						|
}
 | 
						|
 | 
						|
type testController struct {
 | 
						|
}
 | 
						|
 | 
						|
func (tc testController) Test(ctx *gin.Context, requestData *testForm) (*testCommon, error) {
 | 
						|
	return &testCommon{UserID: requestData.UserID}, nil
 | 
						|
}
 |