1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-08-10 22:31:32 +02:00

fix: initial release

Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
This commit is contained in:
Dr. Carsten Leue
2023-07-17 18:03:21 +02:00
parent 69c2fe1118
commit 2efe4f64c5
18 changed files with 890 additions and 115 deletions

View File

@@ -30,7 +30,12 @@ type (
)
var (
NewRequest = RIOE.Eitherize3(http.NewRequestWithContext)
// MakeRequest is an eitherized version of [http.NewRequestWithContext]
MakeRequest = RIOE.Eitherize3(http.NewRequestWithContext)
makeRequest = F.Bind13of3(MakeRequest)
// specialize
MakeGetRequest = makeRequest("GET", nil)
)
func (client client) Do(req Requester) RIOE.ReaderIOEither[*http.Response] {
@@ -66,6 +71,21 @@ func ReadFullResponse(client Client) func(Requester) RIOE.ReaderIOEither[H.FullR
}
}
// func test(resp *http.Response) IOE.IOEither[error, H.FullResponse] {
// x := F.Pipe3(
// resp,
// T.Replicate2[*http.Response],
// T.Map2(
// IOE.Of[error, *http.Response],
// F.Flow3(
// H.GetBody,
// IOE.Of[error, io.ReadCloser],
// IOEF.ReadAll[io.ReadCloser],
// ),
// ),
// )
// }
// ReadAll sends a request and reads the response as bytes
func ReadAll(client Client) func(Requester) RIOE.ReaderIOEither[[]byte] {
return F.Flow2(

View File

@@ -19,7 +19,7 @@ func TestSendSingleRequest(t *testing.T) {
client := MakeClient(H.DefaultClient)
req1 := NewRequest("GET", "https://jsonplaceholder.typicode.com/posts/1", nil)
req1 := MakeGetRequest("https://jsonplaceholder.typicode.com/posts/1")
readItem := ReadJson[PostItem](client)