Files
htwkalender/services/ical/service/connector/restHandler.go
2024-06-10 18:07:54 +02:00

60 lines
1001 B
Go

package connector
import (
"github.com/gofiber/fiber/v3/client"
"htwkalender-ical/model"
"time"
)
const host = "http://htwkalender-data-manager:8090"
func RequestApi(path string) (*client.Response, error) {
cc := client.New()
cc.SetTimeout(5 * time.Second)
// set retry to 0
response, err := cc.Get(host + path)
if err != nil {
return nil, err
}
return response, nil
}
func DeleteRequestApi(path string) error {
cc := client.New()
cc.SetTimeout(5 * time.Second)
// set retry to 0
_, err := cc.Delete(host + path)
if err != nil {
return err
}
return nil
}
func PostRequestApi(path string, body []model.FeedCollection) (*client.Response, error) {
cc := client.New()
cc.SetTimeout(5 * time.Second)
config := client.Config{
Body: body,
Header: map[string]string{
"Content-Type": "application/json",
"Accept": "*/*",
},
}
// set retry to 0
response, err := cc.Post(host+path, config)
if err != nil {
return nil, err
}
return response, nil
}