mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2026-01-16 19:42:26 +01:00
60 lines
1001 B
Go
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
|
|
}
|