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:
parent
1fb48800a1
commit
8feca959d4
2 changed files with 22 additions and 13 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue