Documentation
¶
Overview ¶
Package at provides annotations for struct, function, or method
Package at provides annotations for web RestController ¶
Copyright 2018~now John Deng (hi.devops.io@gmail.com).
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- type AfterInit
- type AfterMethod
- type AllowNil
- type Annotation
- type AnyMapping
- type AutoConfiguration
- type AutoWired
- type BaseAnnotation
- type BeforeInit
- type BeforeMethod
- type Component
- type Conditional
- type ConditionalOnField
- type ConfigurationProperties
- type Consumes
- type ContextAwaredeprecated
- type ContextPath
- type DeleteMapping
- type EnableScheduling
- type ExternalDocs
- type FileServer
- type GetMapping
- type Header
- type HealthCheckService
- type HiBootApplication
- type HttpMethod
- type HttpMethodSubscriber
- type JwtRestController
- type Logical
- type Method
- type Middleware
- type MiddlewareHandler
- type MiddlewarePostHandler
- type Operation
- type OptionsMapping
- type Parameter
- type PatchMapping
- type PathVariable
- type PostMapping
- type Produces
- type PutMapping
- type Qualifier
- type RequestBody
- type RequestForm
- type RequestMapping
- type RequestParams
- type RequiresAuthentication
- type RequiresGuest
- type RequiresLogical
- type RequiresPermissions
- type RequiresRoles
- type RequiresUser
- type Response
- type ResponseBody
- type ResponseData
- type RestController
- type Scheduled
- type Schema
- type Scope
- type Swagger
- type Tag
- type Tags
- type TraceMapping
- type UseJwt
- type UseMiddleware
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AfterInit ¶ added in v1.8.0
type AfterInit struct {
Annotation `json:"-"`
BaseAnnotation
}
type AfterMethod ¶ added in v1.5.0
type AfterMethod struct {
Annotation
HttpMethod
}
AfterMethod is the annotation that set the called after the http method of a controller
type AllowNil ¶ added in v1.5.0
type AllowNil struct {
Annotation
BaseAnnotation
}
type Annotation ¶ added in v1.5.0
type Annotation struct {
}
Annotation is an empty struct that indicates the struct as an annotation
type AnyMapping ¶ added in v1.5.0
type AnyMapping struct {
Annotation
RequestMapping
AtMethod string `value:"ANY" at:"method" json:"-"`
}
AnyMapping is the annotation that set the AnyMapping of a controller
type AutoConfiguration ¶ added in v0.9.7
type AutoConfiguration struct {
Annotation
BaseAnnotation
}
AutoConfiguration is the annotation of auto configuration
type AutoWired ¶ added in v1.5.0
type AutoWired struct {
Annotation
BaseAnnotation
}
AutoWired is the annotation that auto inject instance to object
type BaseAnnotation ¶ added in v1.5.0
type BaseAnnotation struct {
Annotation `json:"-"`
AtValue string `json:"-" at:"value"`
}
BaseAnnotation is the base of an annotation
type BeforeInit ¶ added in v1.8.0
type BeforeInit struct {
Annotation `json:"-"`
BaseAnnotation
}
type BeforeMethod ¶ added in v1.5.0
type BeforeMethod struct {
Annotation
HttpMethod
}
BeforeMethod is the annotation that set the called before the http method of a controller
type Component ¶ added in v0.11.0
type Component struct {
Annotation
BaseAnnotation
}
Component is the annotation that the dependency is injected in app init.
type Conditional ¶ added in v1.5.0
type Conditional struct {
Annotation
BaseAnnotation
}
Conditional check if the string value of any give condition of the struct
type Example struct {
at.Conditional `value:"your-condition-express"`
Name string
}
type ConditionalOnField ¶ added in v1.8.0
type ConditionalOnField struct {
Annotation
BaseAnnotation
}
ConditionalOnField annotation check if the string value of give fields of the struct
type Example struct {
at.ConditionalOnField `value:"Namespace,Name"`
Namespace string
Name string
}
type ConfigurationProperties ¶ added in v0.9.8
type ConfigurationProperties struct {
Annotation
BaseAnnotation
}
ConfigurationProperties is the annotation that annotate configuration properties
type Consumes ¶ added in v1.5.0
type Consumes struct {
Annotation
Swagger
AtValues []string `at:"values" json:"-"`
}
Consumes corresponds to the `consumes` field of the operation. Takes in comma-separated values of content types. For example, "application/json, application/xml" would suggest this API Resource accepts JSON and XML input. example:
at struct {
at.Consumes `values:"application/json,application/xml"`
}
type ContextAware
deprecated
added in
v0.11.0
type ContextAware struct {
Annotation
Scope `value:"request"`
}
ContextAware is the annotation that has the ability of a component to be injected when method of Rest Controller is requested.
type Example struct {
at.Scope `value:"request"`
...
}
Deprecated: use at.Scope `value:"request"` instead
type ContextPath ¶ added in v0.11.0
type ContextPath struct {
Annotation
BaseAnnotation
}
ContextPath is the annotation that set the context path of a controller
type DeleteMapping ¶ added in v1.5.0
type DeleteMapping struct {
Annotation
RequestMapping
AtMethod string `method:"DELETE" at:"method" json:"-"`
}
DeleteMapping is the annotation that set the DeleteMapping of a controller
type EnableScheduling ¶ added in v1.6.0
type EnableScheduling struct {
Annotation
BaseAnnotation
}
EnableScheduling enables scheduling
type ExternalDocs ¶ added in v1.5.0
type ExternalDocs struct {
Annotation
Swagger
AtDescription string `at:"description" json:"-"`
AtURL string `at:"url" json:"-"`
}
ExternalDocs
type FileServer ¶ added in v1.5.0
type FileServer struct {
Annotation
RequestMapping
}
StaticResource is the annotation that set the StaticResource of a controller value: static resource dir
type GetMapping ¶ added in v1.5.0
type GetMapping struct {
Annotation
RequestMapping
AtMethod string `method:"GET" at:"method" json:"-"`
}
GetMapping is the annotation that set the GetMapping of a controller
type Header ¶ added in v1.5.0
type Header struct {
Annotation
Swagger
AtType string `at:"type" json:"-"`
AtFormat string `at:"format" json:"-"`
AtDescription string `at:"description" json:"-"`
}
Header is the annotation that annotate the header
type HealthCheckService ¶ added in v0.10.2
type HealthCheckService struct {
Annotation
BaseAnnotation
}
HealthCheckService is the annotation for health check service
type HiBootApplication ¶ added in v1.5.0
type HiBootApplication struct {
Annotation
BaseAnnotation
}
HiBootApplication is the main entry point of the application
type HttpMethod ¶ added in v1.5.0
type HttpMethod struct {
Annotation
BaseAnnotation
AtNoContextPath bool `json:"-" at:"no_context_path"`
}
HttpMethod is the annotation that the http method of a controller
type HttpMethodSubscriber ¶ added in v1.5.0
type HttpMethodSubscriber struct {
Annotation
BaseAnnotation
}
type JwtRestController ¶ added in v0.11.0
type JwtRestController struct {
Annotation
RestController
UseJwt
}
JwtRestController is the annotation that declare current controller is the RESTful Controller with JWT support
type Method ¶ added in v1.5.0
type Method struct {
Annotation
BaseAnnotation
}
Method is the annotation that set the RequestMethod of a controller
type Middleware ¶ added in v1.5.0
type Middleware struct {
Annotation
BaseAnnotation
}
Middleware is the annotation that annotate the controller or method use middleware
type MiddlewareHandler ¶ added in v1.5.0
type MiddlewareHandler struct {
Annotation
BaseAnnotation
}
MiddlewareHandler is the annotation that annotate the controller or method use middleware
type MiddlewarePostHandler ¶ added in v1.5.0
type MiddlewarePostHandler struct {
Annotation
BaseAnnotation
}
MiddlewarePostHandler is the annotation that annotate the controller or method use middleware
type Operation ¶ added in v1.5.0
type Operation struct {
Annotation
Swagger
AtID string `at:"id" json:"-"`
AtDescription string `at:"description" json:"-"`
AtSummary string `at:"summary" json:"-"`
AtDeprecated bool `at:"deprecated" json:"-"`
}
Operation Describes an operation or typically a HTTP method against a specific path. Operations with equivalent paths are grouped in a single Operation Object. A combination of a HTTP method and a path creates a unique operation. example:
func (c *) CreateEmployee(at struct{
at.PostMapping `value:"/"`
at.Operation `id:"Create Employee" description:"This is the employee creation api"`
}, request EmployeeRequest) {
...
}
type OptionsMapping ¶ added in v1.5.0
type OptionsMapping struct {
Annotation
RequestMapping
AtMethod string `method:"OPTIONS" at:"method" json:"-"`
}
OptionsMapping is the annotation that set the OptionsMapping of a controller
type Parameter ¶ added in v1.5.0
type Parameter struct {
Annotation
Swagger
AtName string `at:"name" json:"-"`
AtType string `at:"type" json:"-"`
AtIn string `at:"in" json:"-"`
AtDescription string `at:"description" json:"-"`
}
ApiParam annotation to add additional meta-data for operation parameters
func (c *) CreateEmployee(at struct{
at.PostMapping `value:"/"`
at.Parameter `value:"Employee object store in database table" required:"true"`
}, request EmployeeRequest) {
...
}
Parameter
type PatchMapping ¶ added in v1.5.0
type PatchMapping struct {
Annotation
RequestMapping
AtMethod string `method:"PATCH" at:"method" json:"-"`
}
PatchMapping is the annotation that set the PatchMapping of a controller
type PathVariable ¶ added in v1.5.0
type PathVariable struct {
Annotation
BaseAnnotation
}
PathVariable the annotation PathVariable
type PostMapping ¶ added in v1.5.0
type PostMapping struct {
Annotation
RequestMapping
AtMethod string `method:"POST" at:"method" json:"-"`
}
PostMapping is the annotation that set the PostMapping of a controller
type Produces ¶ added in v1.5.0
type Produces struct {
Annotation
Swagger
AtValues []string `at:"values" json:"-"`
}
Produces corresponds to the `produces` field of the operation. Takes in comma-separated values of content types. For example, "application/json, application/xml" would suggest this operation generates JSON and XML output. example:
at struct {
at.Consumes `values:"application/json,application/xml"`
}
type PutMapping ¶ added in v1.5.0
type PutMapping struct {
Annotation
RequestMapping
AtMethod string `method:"PUT" at:"method" json:"-"`
}
PutMapping is the annotation that set the PutMapping of a controller
type Qualifier ¶
type Qualifier struct {
Annotation
BaseAnnotation
}
Qualifier is the annotation that used for disambiguate the references.
type RequestBody ¶ added in v0.11.0
type RequestBody struct {
Annotation
BaseAnnotation
}
RequestBody the annotation RequestBody
type RequestForm ¶ added in v0.11.0
type RequestForm struct {
Annotation
BaseAnnotation
}
RequestForm the annotation RequestForm
type RequestMapping ¶ added in v1.5.0
type RequestMapping struct {
Annotation
HttpMethod
}
RequestMapping is the annotation that set the RequestMapping of a controller
type RequestParams ¶ added in v0.11.0
type RequestParams struct {
Annotation
BaseAnnotation
}
RequestParams the annotation RequestParams
type RequiresAuthentication ¶ added in v1.5.0
type RequiresAuthentication struct {
Annotation
BaseAnnotation
}
RequiresAuthentication is the annotation that annotate the method for authorization
type RequiresGuest ¶ added in v1.5.0
type RequiresGuest struct {
Annotation
BaseAnnotation
}
RequiresGuest is the annotation that annotate the method for requires guest
type RequiresLogical ¶ added in v1.5.0
type RequiresLogical struct {
Annotation
BaseAnnotation
// AtLogical is the logical operator, default value is 'and'
AtLogical Logical `json:"-" at:"logical" logical:"and"` // default value is and
}
RequiresLogical is the annotation that annotate the method for requires logical
type RequiresPermissions ¶ added in v1.5.0
type RequiresPermissions struct {
Annotation
RequiresLogical
// AtValues hold the permission values as an array, e.g. `values:"user:read,team:read"`
AtValues []string `at:"values" json:"-"`
// AtType is for data permission, user can specify his/her own type and then implement it in middleware, e.g. `type:"pagination"`
AtType string `json:"-" at:"type"`
// AtIn is the input field name of query parameters, e.g. `in:"page,per_page"`; page,per_page is the default values that indicate
AtIn []string `json:"-" at:"in"`
// AtOut is the output field name of query parameters, e.g. `out:"expr"` <where in (1,2,3)>; expr is the default value, it can be any query parameters field name
AtOut []string `json:"-" at:"out"`
}
RequiresPermissions is the annotation that annotate the method for requires permissions
type RequiresRoles ¶ added in v1.5.0
type RequiresRoles struct {
Annotation
RequiresLogical
}
RequiresRoles is the annotation that annotate the method for requires roles
type RequiresUser ¶ added in v1.5.0
type RequiresUser struct {
Annotation
BaseAnnotation
}
RequiresUser is the annotation that annotate the method for requires users
type Response ¶ added in v1.5.0
type Response struct {
Annotation
Swagger
AtCode int `at:"code" json:"-"`
AtDescription string `at:"description" json:"-"`
}
Response is the response type of the operation. example:
Responses struct {
StatusOK struct {
at.Response `code:"200" description:"returns a greeting"`
at.Schema `type:"string" description:"contains the actual greeting as plain text"`
}
StatusNotFound struct {
at.Response `code:"404" description:"greeter is not available"`
at.Schema `type:"string" description:"Report 'not found' error message"`
}
}
type ResponseBody ¶ added in v0.11.0
type ResponseBody struct {
Annotation
BaseAnnotation
}
ResponseBody the annotation ResponseBody
type ResponseData ¶ added in v0.11.0
type ResponseData struct {
Annotation
BaseAnnotation
}
ResponseData the annotation ResponseData
type RestController ¶ added in v0.9.7
type RestController struct {
Annotation
BaseAnnotation
}
RestController is the annotation that declare current controller is the RESTful Controller
type Scheduled ¶ added in v1.6.0
type Scheduled struct {
Annotation
BaseAnnotation
// limit times
AtLimit *int `at:"limit" json:"-"`
// standard cron expressions
AtCron *string `at:"cron" json:"-"`
// number
AtEvery *int `at:"every" json:"-"`
// valid units are: milliseconds, seconds, minutes, hours, days, weeks, months
AtUnit *string `at:"unit" json:"-"`
// at
AtTime *string `at:"time" json:"-"`
// tag
AtTag *string `at:"tag" json:"-"`
// delay
AtDelay *int64 `at:"delay" json:"-"`
// sync
AtSync *bool `at:"sync" json:"-"`
}
Scheduled is the annotation that annotate for scheduler
type Schema ¶ added in v1.5.0
type Schema struct {
Annotation
Swagger
AtType string `at:"type" json:"-"`
AtDescription string `at:"description" json:"-"`
}
Schema is the annotation that annotate Response or Parameter's properties example:
Responses struct {
StatusOK struct {
at.Response `code:"200" description:"returns a greeting"`
at.Schema `type:"string" description:"contains the actual greeting as plain text"`
}
StatusNotFound struct {
at.Response `code:"404" description:"greeter is not available"`
at.Schema `type:"string" description:"Report 'not found' error message"`
}
}
type Scope ¶ added in v1.8.0
type Scope struct {
Annotation `json:"-"`
BaseAnnotation
}
type Swagger ¶ added in v1.5.0
type Swagger struct {
Annotation
BaseAnnotation
}
Swagger is the annotation group - swagger
type Tag ¶ added in v1.5.0
type Tag struct {
Annotation
BaseAnnotation
}
Tag the annotation Tag, tell the injector that the struct implements a tag
type Tags ¶ added in v1.5.0
type Tags struct {
Annotation
Swagger
AtValues []string `at:"values" json:"-"`
}
Tags
type TraceMapping ¶ added in v1.5.0
type TraceMapping struct {
Annotation
RequestMapping
AtMethod string `method:"TRACE" at:"method" json:"-"`
}
TraceMapping is the annotation that set the TraceMapping of a controller
type UseMiddleware ¶ added in v1.5.0
type UseMiddleware struct {
Annotation
Conditional
}
UseMiddleware is the annotation that that annotate the controller or method use middleware based on condition