Documentation ¶
Index ¶
- Constants
- Variables
- func ConflictAnnotationError(ann string, value fmt.Stringer) error
- func DuplicatedAnnotationError(ann string) error
- func DuplicatedHttpMethodError(method string) error
- func GetType(name string) types.Type
- func IdNotExistError(id string) error
- func Impl(service *Service, pkg string) (code string, err error)
- func PatternIdTypeMustBeIntOrStringError(id string) error
- func UnsupportedAnnotationValueError(ann, value string) error
- type BodyMeta
- type BodyType
- type IdList
- type Method
- type MethodMeta
- func (meta *MethodMeta) TryAddCookie(key, value string) (err error)
- func (meta *MethodMeta) TryAddHeader(key, value string) (err error)
- func (meta *MethodMeta) TryAddParam(key, pattern string, typ ParamType) (err error)
- func (meta *MethodMeta) TrySetBodyType(value string) (err error)
- func (meta *MethodMeta) TrySetMethod(httpMethod, uriPattern string) (err error)
- func (meta *MethodMeta) TrySetResultType(value string) (err error)
- func (meta *MethodMeta) TrySetSingleBodyType(value string) (err error)
- type ParamMeta
- type ParamType
- type PatternMeta
- type Service
- type ServiceMeta
Constants ¶
View Source
const ( // <Annotation Val> first annotations. etc. @Get /item/{id} | @Get GetAnn = "@Get" // path HeadAnn = "@Head" PostAnn = "@Post" PutAnn = "@Put" PatchAnn = "@Patch" DeleteAnn = "@Delete" ConnectAnn = "@Connect" OptionsAnn = "@Options" TraceAnn = "@Trace" BodyAnn = "@Body" // json | xml | form | multipart; default json SingleBodyAnn = "@SingleBody" // json | xml | form | multipart; default json; if singleBody, the type of single body var must be IOReader or Other ResultAnn = "@Result" // json | xml ; default json BaseAnn = "@Base" )
View Source
const ( // <Annotation(Key) Val> second annotations. etc. @Header(Content-Type) multipart/form | @Header(Content-Type) ParamAnn = "@Param" HeaderAnn = "@Header" // param type: string CookieAnn = "@Cookie" // param type: string FileAnn = "@File" // param type: string )
View Source
const ( // resp, error HttpResponse = "http_response" // req, error HttpRequest = "http_request" // resp, statusCode, error HTML = "html" )
View Source
const ( // resp, statusCode, error JSON = "json" // resp, statusCode, error XML = "xml" )
View Source
const ( // resp, statusCode, error Form = "form" // resp, statusCode, error Multipart = "multipart" )
View Source
const ( DuplicatedAnnotation = "duplicated annotation" DuplicatedHttpMethod = "duplicated http method" IdNotExist = "id does not exist" PatternIdTypeMustBeIntOrString = "id in pattern must be int or string" PatternKeyMustNotBeEmpty = "key of pattern must not be empty" SingleBodyWithMultiBodyVars = "singleBody with multi body vars" ConflictAnnotation = "annotation conflict" UnsupportedAnnotationValue = "annotation value is unsupported" )
View Source
const ( FieldBaseUrl = "baseUrl" FieldHeader = "header" FieldCookies = "cookies" )
View Source
const ( // packages HttpPkg = "net/http" EncodingJSON = "encoding/json" EncodingXML = "encoding/xml" Bytes = "bytes" Ioutil = "io/ioutil" NetURL = "net/url" IO = "io" MultipartPkg = "mime/multipart" Textproto = "net/textproto" OS = "os" StringsPkg = "strings" FormatPkg = "fmt" UnHTMLPkg = "github.com/Hexilee/unhtml" )
View Source
const ( // types IntToken = "int" StringToken = "string" ErrorToken = "error" )
View Source
const ( IdRegexp = `\{[a-zA-Z_][0-9a-zA-Z_]*\}` StringPlaceholder = "%s" IntPlaceholder = "%d" )
View Source
const ( // ids IdResult = "genResult" IdRequest = "genRequest" IdResponse = "genResponse" IdClient = "genClient" IdStatusCode = "genStatusCode" IdError = "genErr" IdUri = "genUri" IdUrl = "genFinalUrl" IdData = "genData" IdResultData = "genResultData" IdBody = "genBody" IdDataMap = "genDataMap" IdPartWriter = "genPartWriter" IdBodyWriter = "genBodyWriter" IdFile = "genFile" IdFilePath = "genFilePath" IdCookie = "genCookie" IdHeaderKey = "genHeaderKey" IdHeaderSlice = "genHeaderSlice" IdHeaderValue = "genHeaderValue" IdHeader = "genHeader" )
View Source
const ( TypeInt = iota TypeString IOReader TypeFile Other )
View Source
const ( TokenType = "type" ZeroStr = "" LF = "\n" )
View Source
const ( TypeIOReader = "IOReader" TypeErr = "Err" TypeStatusCode = "StatusCode" TypeRequest = "Request" TypeResponse = "Response" )
View Source
const (
Src = `` /* 157-byte string literal not displayed */
)
Variables ¶
View Source
var (
IdRe = regexp.MustCompile(IdRegexp)
)
Functions ¶
func IdNotExistError ¶
Types ¶
type BodyMeta ¶
type BodyMeta struct { *PatternMeta // contains filtered or unexported fields }
type Method ¶
type Method struct { *types.Func *MethodMeta // contains filtered or unexported fields }
type MethodMeta ¶
type MethodMeta struct {
// contains filtered or unexported fields
}
func (*MethodMeta) TryAddCookie ¶
func (meta *MethodMeta) TryAddCookie(key, value string) (err error)
func (*MethodMeta) TryAddHeader ¶
func (meta *MethodMeta) TryAddHeader(key, value string) (err error)
func (*MethodMeta) TryAddParam ¶
func (meta *MethodMeta) TryAddParam(key, pattern string, typ ParamType) (err error)
func (*MethodMeta) TrySetBodyType ¶
func (meta *MethodMeta) TrySetBodyType(value string) (err error)
func (*MethodMeta) TrySetMethod ¶
func (meta *MethodMeta) TrySetMethod(httpMethod, uriPattern string) (err error)
func (*MethodMeta) TrySetResultType ¶
func (meta *MethodMeta) TrySetResultType(value string) (err error)
func (*MethodMeta) TrySetSingleBodyType ¶
func (meta *MethodMeta) TrySetSingleBodyType(value string) (err error)
type ParamMeta ¶
type ParamMeta struct {
// contains filtered or unexported fields
}
func NewParamMeta ¶
type PatternMeta ¶
type PatternMeta struct {
// contains filtered or unexported fields
}
type Service ¶
type Service struct { *ServiceMeta // contains filtered or unexported fields }
func (*Service) InitComments ¶
func (srv *Service) InitComments(cmap ast.CommentMap) *Service
func (*Service) TryAddField ¶
func (*Service) TrySetNode ¶
type ServiceMeta ¶
type ServiceMeta struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.