fp-go-http

Builds and executes composable HTTP requests in Go using the fp-go ReaderIOResult monad.

2.0k|83|Updated Jul 5, 2023
One-click install
npx skills add https://github.com/IBM/fp-go --skill fp-go-http
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fp-go-http
Source: https://github.com/IBM/fp-go/tree/main/gen/v2/data/skills/fp-go-http
Command: npx skills add https://github.com/IBM/fp-go --skill fp-go-http

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing HTTP clients in Go with fp-go requires understanding the ReaderIOResult monad, lazy execution, and error propagation through the Result type, which is unfamiliar to most Go developers. This Skill provides the patterns and APIs needed to construct, execute, and compose HTTP requests idiomatically within the fp-go v2 ecosystem.

Core Features & Use Cases

  • Request Construction: Create GET requests with MakeGetRequest, arbitrary requests with MakeRequest, or complex requests via the builder API (WithURL, WithJSON, WithBearer, WithHeader, WithQueryArg).
  • Typed Response Parsing: Use ReadJSON, ReadText, ReadAll, or ReadFullResponse to validate status codes and Content-Type before decoding response bodies into typed structs.
  • Parallel Requests: Run homogeneous requests concurrently with TraverseArray or heterogeneous requests with TraverseTuple2, keeping full type safety.
  • Use Case: Fetch a list of posts and an unrelated cat fact from two different APIs in parallel, decode each into its own Go struct, and propagate any error automatically to a single handling point in an HTTP handler.

Quick Start

Ask the AI to write Go code using fp-go that fetches JSON from an API endpoint with the ReaderIOResult HTTP client and decodes it into a typed struct.

Frequently Asked Questions about fp-go-http

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I make an HTTP request with fp-go in Go?

Create a client with H.MakeClient, build a request with H.MakeGetRequest or H.MakeRequest, then pass it to a reader like H.ReadJSON. The result is lazy and executes only when called with a context.Context.

How to run parallel HTTP requests with different response types in fp-go?

Use RIO.TraverseTuple2 to run two requests with different response types concurrently, or TraverseArray when all requests return the same type. Results arrive as a typed tuple or array with errors propagated automatically.

Does the fp-go HTTP client support custom headers and authentication?

Yes, the builder package provides WithHeader for arbitrary headers, WithBearer for Authorization tokens, WithQueryArg for query parameters, and WithJSON for JSON bodies with automatic Content-Type. Compose them with function.Pipe on B.Default.

What Go version does the fp-go v2 HTTP package require?

The fp-go v2 HTTP client requires Go 1.24 or later. It lives under github.com/IBM/fp-go/v2/context/readerioresult/http and wraps the standard net/http package.

How are HTTP errors handled in the fp-go ReaderIOResult monad?

Errors from request creation, non-success status codes, Content-Type mismatches, and JSON decoding all propagate through the Result monad automatically. You handle them once at the call site via direct error checking or RIO.Fold.