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
21
internal/api/make.go
Normal file
21
internal/api/make.go
Normal 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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue