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
Adrien Marquès
cb7f22e03d
remove useless readme assets
continuous-integration/drone/push Build is passing
Details
2020-03-28 15:45:56 +01:00
Adrien Marquès
d3e8d48bc3
Merge branch 'refactor/const-api-errors' of go/aicra into 0.3.0
...
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/tag Build is passing
Details
allow constants for api.Error and update api.Handler signature
- api.EmtyResponse().WithError(api.Error) is the new interface for api.Response
- handlers return an api.Response that is wrapped into the final response
- server.HandleFunc becomes server.Handle
2020-03-28 14:01:08 +00:00
Adrien Marquès
af09466013
migrate api.response to const errors; make HandlerFn return an api.Error; rename http HandlFunc to Handle;
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/pr Build is passing
Details
2020-03-28 14:57:28 +01:00
Adrien Marquès
5504e4b3ec
make api errors int; allow for const defaults
2020-03-28 14:51:49 +01:00
Adrien Marquès
2f9534a3b0
Merge branch 'refactor/config-validator' of go/aicra into 0.3.0
...
continuous-integration/drone/push Build is passing
Details
add validator interface to unify and for readability in internal/config
2020-03-28 11:33:34 +00:00
Adrien Marquès
49cf06d5d8
implement validator interface for config.server; refactor
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/pr Build is passing
Details
2020-03-28 12:31:44 +01:00
Adrien Marquès
af3ffa7d6a
implement validator interface for config.service; rename for readability
2020-03-28 12:30:57 +01:00
Adrien Marquès
dac9aa4298
implement validator interface for config.parameter
2020-03-28 12:28:58 +01:00
Adrien Marquès
54705b7472
create validator interface for config
2020-03-28 12:26:11 +01:00
Adrien Marquès
5f3aa5967d
provide datatype registry to every type to allow for recursive datatypes : slices, maps, structs
2020-03-22 16:50:10 +01:00
Adrien Marquès
eef94ff998
also check method when finding missing handlers
2020-03-22 16:37:43 +01:00
Adrien Marquès
97cf19d7b4
update readme
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/tag Build is passing
Details
2020-03-22 15:03:35 +01:00
Adrien Marquès
d57f60c710
set content-type to json before writing response
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/tag Build is passing
Details
2020-03-22 14:05:47 +01:00
Adrien Marquès
ad6de97979
fix: actually get service handler
2020-03-22 14:05:32 +01:00
Adrien Marquès
2ee48560b6
make ToHTTPServer() check for missing handlers
...
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/tag Build is passing
Details
- check for missing handlers in ToHTTPServer()
- rename HTTP() to ToHTTPServer()
- remove logs
2020-03-21 16:53:19 +01:00
Adrien Marquès
a15a5c1f7a
fix: register mismatch when no brace capture
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/tag Build is passing
Details
2020-03-21 15:58:05 +01:00
Adrien Marquès
5fe983c486
display both services in pattern collision error messages
2020-03-21 15:57:35 +01:00
Adrien Marquès
3017cc5ba9
add method tests for pattern collision
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/tag Build is passing
Details
2020-03-21 15:52:07 +01:00
Adrien Marquès
9c3166397f
add tests for service collision
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/tag Build is passing
Details
2020-03-21 15:49:07 +01:00
Adrien Marquès
e3adbf48ca
consider collision only if every part is matching
2020-03-21 15:48:59 +01:00
Adrien Marquès
0e6dfbe580
make pattern collission error message explicit
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/tag Build is passing
Details
2020-03-21 15:15:33 +01:00
Adrien Marquès
d6c22b5ff0
adapt server to previous api changes
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/tag Build is passing
Details
2020-03-21 14:49:36 +01:00
Adrien Marquès
9a5b0dd6e3
remove Parameter type, only keep method parseParameter()
2020-03-21 14:45:39 +01:00
Adrien Marquès
149ec9a9a0
internal/reqdata Parse() does not return errors anymore
2020-03-21 14:20:26 +01:00
Adrien Marquès
3a258400c0
remove api useless errors : UnkonwnMethod and UncallableMethod
2020-03-21 14:19:35 +01:00
Adrien Marquès
9475fe4526
use private errors do avoid overlapping types among packages
2020-03-21 14:19:14 +01:00
Adrien Marquès
3606f9984d
update tests for internal/reqdata set
continuous-integration/drone/push Build is failing
Details
2020-03-20 22:36:15 +01:00
Adrien Marquès
7b812c6648
get data from multipart components
2020-03-20 22:35:53 +01:00