-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigureapi.go
More file actions
42 lines (35 loc) · 808 Bytes
/
configureapi.go
File metadata and controls
42 lines (35 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package session
import (
"fmt"
"io/ioutil"
"encoding/json"
)
type apiConfig struct {
routelist []routedetail
}
type routedetail struct {
Api string `json:"api"`
Methods []string `json:"methods"`
Destination string `json:"destination"`
Authorization bool `json:"authorization"`
}
func GetApiConfig() *apiConfig {
return &apiConfig{
routelist: getapidetails(apiconfigfile),
}
}
func getapidetails(configfile string) []routedetail {
fmt.Println("fetching api details")
file, e := ioutil.ReadFile(configfile)
if e != nil {
fmt.Println("Error in reading file")
return []routedetail{}
}
var jsondata []routedetail
json.Unmarshal(file, &jsondata)
fmt.Println("configuration read successfully")
for _, element := range jsondata{
fmt.Println("api", element.Api)
}
return jsondata
}