-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinfo.go
35 lines (31 loc) · 1.08 KB
/
info.go
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
package microservicecore
import (
"net/http"
"github.com/LUSHDigital/microservice-core-golang/env"
)
// MicroserviceInfo - Represents information about this microservice.
type MicroserviceInfo struct {
ServiceName string `json:"service_name"`
ServiceType string `json:"service_type"`
ServiceScope string `json:"service_scope"`
ServiceVersion string `json:"service_version"`
Endpoints []Route `json:"endpoints"`
}
// Route defines an HTTP route
type Route struct {
Path string `json:"uri"`
Method string `json:"method"`
Handler func(http.ResponseWriter, *http.Request) `json:"-"`
}
// GetMicroserviceInfo - Get the information about this microservice.
//
// Return:
// *MicroserviceInfo - Object representing this microservice.
func GetMicroserviceInfo() *MicroserviceInfo {
return &MicroserviceInfo{
ServiceName: env.MustGet("SERVICE_NAME"),
ServiceType: env.MustGet("SERVICE_TYPE"),
ServiceScope: env.MustGet("SERVICE_SCOPE"),
ServiceVersion: env.MustGet("SERVICE_VERSION"),
}
}