Files
htwkalender/services/ical/service/connector/restHandler.go
2024-06-17 01:14:29 +02:00

58 lines
987 B
Go

package connector
import (
"github.com/gofiber/fiber/v3/client"
"htwkalender/ical/model"
"time"
)
func RequestApi(host string, 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(host string, 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(host string, 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
}