neve-spring

module
v0.0.1-beta.3 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0

README

neve-spring

1. Install

go install github.com/xfali/neve-spring/cmd/neve-spring-gen

2. Usage

2.1 Initialize Project
neve-spring-gen init -o . --main-output cmd/tool-name-dir
2.2 Scan and generate neve registration code
mkdir generated
cd generated
neve-spring-gen -i "spring-test/pkg/service" -o . --trim-path-prefix spring-test/pkg/service
2.3 Import the generated package in main
import _ "spring-test/generated"

3. annotations

category annotation annotation description target parameter parameter type required parameter description example
Dependency injection component component is used to denote a type as component. It means that neve will autodetect these types for dependency injection. 1.type(struct) value string FALSE bean name // +neve:controllor:value="userhandler"
service serive is used to denote a type privides some services. neve will autodetect these types for dependency injection. 1.type(struct) value string FALSE bean name // +neve:service:value="userservice"
controllor controller used with web applications or REST web services. neve will autodetect these types for dependency injection. 1.type(struct) value string FALSE bean name // +neve:controller:value="usercontroller"
bean bean is applied on a function or a method to specify that it returns a bean to be managedd by neve. 1.function 2.method value string FALSE bean name // +neve:bean:value="usercontroller"
initmethod string FALSE specify bean init method (method must be public and have no parameters) // +neve:bean:initmethod="Init"
destroymethod string FALSE specify bean destroy method (method must be public and have no parameters) // +neve:bean:destroymethod="Close"
scope declaring a scope for defining bean 1.type 2.function 3.method value string FALSE scopes: 1.singleton(default) return the same bean instance each time one is needed. 2.prototype produce a new bean instance each time one is needed. // +neve:scope:value="prototype"
REST requestmapping used to map web requests onto specific controller types hand methods. 1.type 2.method value string FALSE URI pattern // +neve:requestmapping:value="/user/:id"
method string FALSE http method (must be all letter uppercase) // +neve:requestmapping:method="POST"
requestparam retrieve the URL query parameters and map it to the method argument. 1.method name string TRUE method argument name // +neve:requestparam:name="projectId",default="-1",required=false
default string FALSE default value
required bool FALSE if parameter is missing and without any default value will response with HTTP 400 error(default false)
pathvariable map the URI variable to one of the method arguments. 1.method name string TRUE method argument name // +neve:pathvariable:name="userId",default="-1",required=true
default string FALSE default value
required bool FALSE if parameter is missing and without any default value will response with HTTP 400 error(default false)
requestheader map the request Header variable to one of the method arguments. 1.method name string TRUE method argument name // +neve:requestheader:name="clientid",default="-1"
default string FALSE default value
required bool FALSE if parameter is missing and without any default value will response with HTTP 400 error(default false)
requestbody map the request body to one of the method arguments. 1.method name string TRUE method argument name // +neve:requestbody:name="clientid"
required bool FALSE if parameter is missing and without any default value will response with HTTP 400 error(default false)
loghttp output http logs 1.method norequestheader bool FALSE output http logs without request header // +neve:loghttp:noresponsebody=true
norequestbody bool FALSE output http logs without request body
noresponseheader bool FALSE output http logs without response header
noresponsebody bool FALSE output http logs without response body
level string FALSE log leve (options:debug | info | warn | error) default into
swagger:apioperation enable swagger 1.method value string TRUE A short summary of what the operation does // +neve:swagger:apioperation:value="create user"
notes string FALSE A verbose explanation of the operation behavior
tags string FALSE A list of tags to each API operation that separated by commas
router string FALSE Path definition that separated by spaces

Jump to

Keyboard shortcuts

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