Commit Graph

393 Commits

Author SHA1 Message Date
Adrien Marquès 10e59acdae
fix: test string-int concatenation warnings 2021-03-28 18:50:25 +02:00
Adrien Marquès 334f1fba21
feat: add builder helpers Get(), Post(), Put(), Delete() that proxies to Bind() 2021-03-28 18:50:04 +02:00
Adrien Marquès 6039fbb41f
update: api.Err system
- rename 'Error' to 'Err'
 - use struct instead of int as underlying type ; remove dependency on 2 maps for reason and HTTP status codes
 - remove useless json implementation
2021-03-28 18:49:23 +02:00
Adrien Marquès a9acfca089
update go.mod to go 1.16 2021-03-28 18:06:09 +02:00
Adrien Marquès fb69dbb903 Merge branch 'refactor-test' of go/aicra into 0.3.0
continuous-integration/drone/tag Build is passing Details
continuous-integration/drone/push Build is passing Details
2020-04-04 15:33:43 +00:00
Adrien Marquès 658c66d2db
update readme
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details
2020-04-04 17:33:08 +02:00
Adrien Marquès 3c453e7f89
remove api useless request, update default errors and bind status codes to errors
continuous-integration/drone/push Build is passing Details
2020-04-04 16:03:50 +02:00
Adrien Marquès d198086dd4
fix http error handlers 2020-04-04 16:03:12 +02:00
Adrien Marquès 30862195a1
config: refactor, simplify, test, remove redundant comments 2020-04-04 15:39:00 +02:00
Adrien Marquès 990bb86919
rework reqdata api and remove redundant comments 2020-04-04 14:56:15 +02:00
Adrien Marquès 35ede5e266
unexport config errors 2020-04-04 14:34:20 +02:00
Adrien Marquès 90472b8bf7
unexport dynfunc errors 2020-04-04 12:46:43 +02:00
Adrien Marquès df56496a16
dynfunc: normalize file names 2020-04-04 12:45:36 +02:00
Adrien Marquès caa57889b4
multipart: rename files and unexport errors 2020-04-04 12:43:55 +02:00
Adrien Marquès 4ba62e19c7
remove func.go and standardize main file name 2020-04-04 12:42:18 +02:00
Adrien Marquès 5cadfcf78b
unexport aicra errors 2020-04-04 12:40:21 +02:00
Adrien Marquès e0ea0c97c5
clarify datatype comments and standardize file name 2020-04-04 12:40:01 +02:00
Adrien Marquès 6319761731 Merge branch 'test/dynamic' of go/aicra into 0.3.0
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
test dynfunc package; standardize and refactor api
2020-04-04 10:09:19 +00:00
Adrien Marquès 92da498d49
remove server logs and util file
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details
2020-04-04 12:06:31 +02:00
Adrien Marquès 60ef4717a8
clarity: aicra server request management 2020-04-04 12:05:17 +02:00
Adrien Marquès 5cc3d2d455
use http.Request instead of pointer 2020-04-04 12:03:29 +02:00
Adrien Marquès c5cdba8007
move aicra builder and server into their own files 2020-04-04 11:50:01 +02:00
Adrien Marquès 09362aad83
make 'dynfunc' internal 2020-04-04 11:49:33 +02:00
Adrien Marquès d69dd2508c
refactor aicra: meaningful defaults, stage renaming Builder.Build() -> Server 2020-04-04 11:46:37 +02:00
Adrien Marquès 1e0fb77d61
standardize and simplify the config package 2020-04-04 11:45:49 +02:00
Adrien Marquès b0e25b431c
ToHTTPServer now returns the exported field http.Handler instead of an unexported type 2020-04-04 10:39:02 +02:00
Adrien Marquès b1498e59c1
clarity rename: dynamic package to dynfunc 2020-04-04 10:36:52 +02:00
Adrien Marquès eb690cf862
add api errors for storage 2020-04-04 10:10:24 +02:00
Adrien Marquès e1606273dd
remove useless func type 2020-04-04 10:10:24 +02:00
Adrien Marquès 8fa18cd61b
enforce dynamic signature check: no input struct allowed when no input is specified 2020-04-04 10:02:48 +02:00
Adrien Marquès db4429b329
ignore empty param renames when creating the spec, not after 2020-03-29 19:33:26 +02:00
Adrien Marquès b48c1d07bf
test: spec add checkOutput() tests for : nil type (ignore type check) ; invalid last output (not api.Error)
continuous-integration/drone/push Build is passing Details
2020-03-29 19:31:08 +02:00
Adrien Marquès 307021bc88
test: spec checkOutput() method
continuous-integration/drone/push Build is passing Details
2020-03-29 19:23:13 +02:00
Adrien Marquès 261e25c127
fix: invert conversion check 2020-03-29 19:23:02 +02:00
Adrien Marquès 438e308f71
merge duplicate errors 2020-03-29 19:22:43 +02:00
Adrien Marquès 7e42c1b6d9
test: spec checkInput() method 2020-03-29 19:14:12 +02:00
Adrien Marquès 66985dfbd0
forbid unexported input/output name 2020-03-29 19:13:07 +02:00
Adrien Marquès 4877d0ea23 Merge branch 'feature/dynamic-handler-signature' of go/aicra into 0.3.0
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
handlers are now managed by the `dynamic` package :
 - handler's signature is `func(inputStruct) (outputStruct, api.Error)`
   - `inputStruct` contains input fields using the name from the field `name`, optional fields are pointers
   - `outputStruct` contains output fields following the same rules as `inputStruct` except optional types are disallowed
   - if no in input, `inputStruct` can be omitted, resulting in `func() (outputStruct, api.Error)`
   - if no output, `outputStruct` can be omitted, resulting in `func(inputStruct) api.Error`
   - as a result, if both input and output are empty; handler signature is `func() api.Error`

datatypes interface contains a `Type() reflect.Type` method to tell what type the result will be cast into :
 - handler `inputStruct` fields are checked against datatypes to check if `datatype.Type()` is convertible to `inputStruct.field`
 - same for output even if no cast is made; it serves as a guard to make sure the contract (config) is satisfied by the implementation.

config parses the `out` field to check for conflicts and find datatypes.
2020-03-29 15:10:04 +00:00
Adrien Marquès 8a0a20294c
rename output fields to original name (not rename)
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
continuous-integration/drone/pr Build is passing Details
2020-03-29 17:01:24 +02:00
Adrien Marquès d7acf771ad
implement the dynamic handler : fill input struct, do the call, fill return struct 2020-03-29 17:01:02 +02:00
Adrien Marquès a5424d8941
parse output in internal/config to find the datatype's reflect.Type() 2020-03-29 16:59:32 +02:00
Adrien Marquès a3daab7de4
dynamic handler output struct must be a pointer; no more a regular struct 2020-03-29 16:58:53 +02:00
Adrien Marquès 00e2a96c79
fix: ErrNoMatchFound error 2020-03-29 16:22:32 +02:00
Adrien Marquès e7dd1e7a56
migrate handler from api to aicra; check for service when setting handler 2020-03-29 15:04:12 +02:00
Adrien Marquès 081e48002f
create dynamic package to handle reflection at runtime to check for handlers signature 2020-03-29 15:00:22 +02:00
Adrien Marquès 974f58fb8e
parse 'out' for internal config
continuous-integration/drone/push Build is passing Details
2020-03-29 14:18:38 +02:00
Adrien Marquès ca2be1415d
enforce 'name' for capture or query parameters 2020-03-29 14:18:05 +02:00
Adrien Marquès b15bb578ce
delegate from internal.service to parameter.Validate() 2020-03-29 14:12:47 +02:00
Adrien Marquès 76cc2f5279
replace datatype.Kind() with Type() 2020-03-28 19:11:23 +01:00
Adrien Marquès 8cfa2235d6
add Kind() method to datatype.T interface and to config parameter 2020-03-28 18:48:27 +01:00