api

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

定义项目 API 的文件 用于描述 HTTP API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterDemoServerV1

func RegisterDemoServerV1(e gin.IRoutes)

RegisterDemoServerV1 Register the gin route for demo server at v1 version

func RegisterRoot

func RegisterRoot(e *gin.Engine)

RegisterRoot Register the gin route for root path

func RegisterServer

func RegisterServer(e *gin.Engine, svc Server)

RegisterServer Register the gin route

Types

type DemoServer

type DemoServer interface {
	Ping(ctx context.Context) error
	// svc: -summary=sayHello -method=get -version=v1 -path=/sayHello -mw=Jwt,LoginNeed
	SayHello(ctx context.Context, req HelloReq) (resp HelloResp, err error)
}

以Server结束的接口,将用作解析API的接口,约定method默认为get,summary和path默认为方法名且首字母小写, 所有指定了version的接口将以/api/{version}作为分组,未指定的将直接使用path DemoServer is the server API for Demo service.

type HelloReq

type HelloReq struct {
	Name string `form:"name" validate:"required"`
}

定义请求内容和正常情况下返回内容

type HelloResp

type HelloResp struct {
	Content string `json:"content"`
}

定义请求内容和正常情况下返回内容

type Server

type Server interface {
	DemoServer
}
var Svc Server

Jump to

Keyboard shortcuts

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