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

21
internal/api/make.go Normal file
View file

@ -0,0 +1,21 @@
package api
import (
"fmt"
)
func Make(name string, args ApiArguments) (ApiInterface, error) {
factories := map[string]Factory{
"v1": EosioV1Factory,
"v2": EosioV2Factory,
"contract": AtomicAssetFactory,
"atomic": AtomicAssetFactory,
"debug": DebugApiFactory,
}
if factory, ok := factories[name]; ok {
return factory(args), nil
}
return nil, fmt.Errorf("invalid API '%s'", name)
}