1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-api-healthcheck synced 2026-06-19 05:10:02 +02:00

internal/server/parse_request.go: move api factory code into its own function in api package: api.Make()

This commit is contained in:
Henrik Hautakoski 2022-11-23 17:14:22 +01:00
parent 1fb48800a1
commit 8feca959d4
No known key found for this signature in database
GPG key ID: 608414D93E862CCD
2 changed files with 22 additions and 13 deletions

View file

@ -33,14 +33,6 @@ func ParseArguments(args []string) api.ApiArguments {
}
func ParseRequest(request string) (api.ApiInterface, error) {
factories := map[string]api.Factory{
"v1": api.EosioV1Factory,
"v2": api.EosioV2Factory,
"contract": api.AtomicAssetFactory,
"atomic": api.AtomicAssetFactory,
"debug": api.DebugApiFactory,
}
// Parse arguments.
// -------------------
p := strings.Split(strings.TrimSpace(request), "|")
@ -51,9 +43,5 @@ func ParseRequest(request string) (api.ApiInterface, error) {
a := ParseArguments(p[1:])
if factory, ok := factories[p[0]]; ok {
return factory(a), nil
}
return nil, fmt.Errorf("invalid API '%s'", p[0])
return api.Make(p[0], a)
}