docs

package
v0.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

type Group struct {
	Dir string
	// contains filtered or unexported fields
}
Example
package main

import (
	"path/filepath"
	"time"

	"github.com/lovego/fs"
	"github.com/lovego/goa"
)

func main() {
	router := goa.New()
	router.DocDir(filepath.Join(fs.SourceDir(), "testdata"))

	accounts := router.Group("/", "账号", "用户、公司、员工、角色、权限")
	accounts.Group("/users", "用户").
		Get(`/`, testHandler).
		Get(`/(?P<type>\w+)/(?P<id>\d+)`, testHandler2)

	accounts.Group("/companies", "公司")

	router.Group("/goods", "商品")
	router.Group("/bill", "单据", "采购、销售")
	router.Group("/storage", "库存")

}

type T struct {
	Type string `c:"类型"`
	Id   *int   `c:"ID"`
	Flag bool   `json:"-" c:"标志"`
}

func testHandler(req struct {
	Title string `用户列表`
	Desc  string `列出所有的用户`
	Query struct {
		Page int `c:"页码"`
		T
	}
	Header struct {
		Cookie string `c:"Cookie中包含会话信息"`
	}
	Body *struct {
		Name *string `c:"名称"`
		T
	}
	Session struct {
		UserId  int64
		LoginAt time.Time
	}
	Ctx *goa.Context
}, resp *struct {
	Data []*struct {
		Id   *int    `c:"ID"`
		Name *string `c:"名称"`
	}
	Error error
}) {
}

func testHandler2(req struct {
	Title string `用户详情`
	Desc  string `获取用户的详细信息`
	Param T
}, resp *struct {
	Header struct {
		SetCookie string `header:"Set-Cookie" c:"返回登录会话"`
	}
	Data struct {
		Id   int    `c:"ID"`
		Name string `c:"名称"`
	}
	Error error
}) {
}
Output:

func (*Group) Child

func (g *Group) Child(path, fullPath string, descs []string) Group

func (*Group) CreateReadme

func (g *Group) CreateReadme(title string, descs []string)

func (*Group) LinkInReadme

func (g *Group) LinkInReadme(title, href string, desc []string, isRoute bool)

func (*Group) Route

func (g *Group) Route(method, path, fullPath string, handler interface{})

func (*Group) SetDir

func (g *Group) SetDir(dir string)

type Route

type Route struct {
	// contains filtered or unexported fields
}

func (*Route) Body

func (r *Route) Body(buf *bytes.Buffer)

func (*Route) Desc

func (r *Route) Desc(buf *bytes.Buffer)

func (*Route) Doc

func (r *Route) Doc(method, fullPath string) []byte

func (*Route) Header

func (r *Route) Header(buf *bytes.Buffer)

func (*Route) MethodPath

func (r *Route) MethodPath(method, fullPath string) string

func (*Route) Param

func (r *Route) Param(buf *bytes.Buffer, fullPath string)

func (*Route) Parse

func (r *Route) Parse(handler interface{}) bool

func (*Route) Query

func (r *Route) Query(buf *bytes.Buffer)

func (*Route) RespBody

func (r *Route) RespBody(buf *bytes.Buffer)

func (*Route) RespError

func (r *Route) RespError(buf *bytes.Buffer)

func (*Route) RespHeader

func (r *Route) RespHeader(buf *bytes.Buffer)

func (*Route) Title

func (r *Route) Title() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL