add personal information service
This commit is contained in:
@@ -8,6 +8,7 @@ type MSHostsConfig struct {
|
|||||||
UsersHost string
|
UsersHost string
|
||||||
StoreHost string
|
StoreHost string
|
||||||
EventsHost string
|
EventsHost string
|
||||||
|
PersonsHost string
|
||||||
}
|
}
|
||||||
|
|
||||||
type ServerConfig struct {
|
type ServerConfig struct {
|
||||||
@@ -26,6 +27,7 @@ func New() *Config {
|
|||||||
UsersHost: getEnv("ASTRA-USERS", "http://localhost:8082"),
|
UsersHost: getEnv("ASTRA-USERS", "http://localhost:8082"),
|
||||||
StoreHost: getEnv("ASTRA-FILE-STORAGE", "http://localhost:8081"),
|
StoreHost: getEnv("ASTRA-FILE-STORAGE", "http://localhost:8081"),
|
||||||
EventsHost: getEnv("ASTRA-EVENTS", "http://localhost:8083"),
|
EventsHost: getEnv("ASTRA-EVENTS", "http://localhost:8083"),
|
||||||
|
PersonsHost: getEnv("ASTRA-PESONAL-INFORMATION", "http://localhost:8083"),
|
||||||
},
|
},
|
||||||
Server: ServerConfig{
|
Server: ServerConfig{
|
||||||
Port: getEnv("PORT", "8080"),
|
Port: getEnv("PORT", "8080"),
|
||||||
|
|||||||
6
main.go
6
main.go
@@ -5,6 +5,7 @@ import (
|
|||||||
"astra-api-gateway/handler"
|
"astra-api-gateway/handler"
|
||||||
"astra-api-gateway/mw"
|
"astra-api-gateway/mw"
|
||||||
"astra-api-gateway/services/events"
|
"astra-api-gateway/services/events"
|
||||||
|
"astra-api-gateway/services/personal-information"
|
||||||
"astra-api-gateway/services/store"
|
"astra-api-gateway/services/store"
|
||||||
"astra-api-gateway/services/users"
|
"astra-api-gateway/services/users"
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
@@ -51,6 +52,11 @@ func main() {
|
|||||||
e.POST("/events", events.CreateEvent)
|
e.POST("/events", events.CreateEvent)
|
||||||
e.DELETE("/events", events.DeleteEvent)
|
e.DELETE("/events", events.DeleteEvent)
|
||||||
|
|
||||||
|
// Persons
|
||||||
|
e.GET("/persons", personal_information.GetPDList)
|
||||||
|
e.GET("/persons/:id", personal_information.GetPD)
|
||||||
|
e.POST("/persons", personal_information.CreatePD)
|
||||||
|
|
||||||
// Store
|
// Store
|
||||||
store_g := e.Group("/store")
|
store_g := e.Group("/store")
|
||||||
store_g.GET("/*", store.GetFileFromStore)
|
store_g.GET("/*", store.GetFileFromStore)
|
||||||
|
|||||||
47
services/personal-information/personal-information.go
Normal file
47
services/personal-information/personal-information.go
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
package personal_information
|
||||||
|
|
||||||
|
import (
|
||||||
|
"astra-api-gateway/config"
|
||||||
|
"astra-api-gateway/pkg/api"
|
||||||
|
"github.com/labstack/echo/v4"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetPDList(c echo.Context) error {
|
||||||
|
data, err, resp := api.GetRequest(
|
||||||
|
config.Env.MSHosts.PersonsHost+"/persons/",
|
||||||
|
c.Request().Header, c.Request().URL.RawQuery)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return c.NoContent(http.StatusBadGateway)
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPD(c echo.Context) error {
|
||||||
|
id := c.Param("id")
|
||||||
|
|
||||||
|
data, err, resp := api.GetRequest(
|
||||||
|
config.Env.MSHosts.PersonsHost+"/persons/"+id,
|
||||||
|
c.Request().Header, c.Request().URL.RawQuery)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return c.NoContent(http.StatusBadGateway)
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreatePD(c echo.Context) error {
|
||||||
|
data, err, resp := api.PostRequest(
|
||||||
|
config.Env.MSHosts.EventsHost+"/persons/",
|
||||||
|
c.Request().Body,
|
||||||
|
c.Request().Header)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return c.NoContent(http.StatusBadGateway)
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user