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:
@@ -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(
|
||||
|
@@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user