Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .release-notes/next-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ end
gist.update_gist(updates)
```

This also adds three new HTTP infrastructure classes: `HTTPPatch` (PATCH with JSON response), `HTTPPut` (PUT expecting 204), and `HTTPCheck` (GET returning Bool based on status code 204/404).

## Add query parameters to GetRepositoryIssues

Expand Down
21 changes: 21 additions & 0 deletions .release-notes/port-to-courier.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Port HTTP transport from ponylang/http to ponylang/courier

The HTTP transport layer has been replaced with ponylang/courier, which uses an actor-based connection model instead of the handler factory pattern. All public API operations work the same way, but `Credentials.auth` has changed type.

Before:
```pony
use "net"

let auth = TCPConnectAuth(env.root)
let creds = Credentials(auth, token)
```

After:
```pony
use lori = "lori"

let auth = lori.TCPConnectAuth(env.root)
let creds = Credentials(auth, token)
```

Authorization headers now use `Bearer` format (`Authorization: Bearer <token>`) instead of the legacy `token` format. GitHub accepts both.
25 changes: 12 additions & 13 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ Uses `corral` for dependency management. `make` automatically runs `corral fetch

## Dependencies

- `github.com/ponylang/http.git` -- HTTP client
- `github.com/ponylang/net_ssl.git` (via http) -- SSL/TLS
- `github.com/ponylang/courier.git` -- HTTP client (actor-based)
- `github.com/ponylang/lori.git` (via courier) -- TCP connections
- `github.com/ponylang/ssl.git` (via courier) -- SSL/TLS
- `github.com/ponylang/web_link.git` -- RFC 8288 Link header parsing
- `github.com/ponylang/json-ng.git` -- JSON parsing (immutable, persistent collections)
- `github.com/ponylang/uri.git` -- RFC 6570 URI template expansion
Expand Down Expand Up @@ -52,16 +53,14 @@ github_rest_api/
user.pony -- User model
license.pony -- License model
json_nav_util.pony -- JsonNavUtil (string_or_none for nullable JSON fields)
paginated_list.pony -- PaginatedList[A] with prev/next page navigation
paginated_list.pony -- PaginatedList[A] with prev/next page navigation, LinkedJsonRequester, LinkedResultReceiver
_extract_pagination_links.pony -- Extracts prev/next URLs from Link headers (via web_link)
request/ -- HTTP request infrastructure (temporary home, intended to be extracted to its own library)
http.pony -- Credentials, ResultReceiver, RequestFactory
http_get.pony -- JsonRequester (GET with JSON response)
http_post.pony -- HTTPPost (POST with JSON response)
http_patch.pony -- HTTPPatch (PATCH with JSON response, expects 200)
http_delete.pony -- HTTPDelete (DELETE, expects 204)
http_put.pony -- HTTPPut (PUT with no body, expects 204)
http_check.pony -- HTTPCheck (GET returning Bool: 204=true, 404=false)
credentials.pony -- Credentials (lori.TCPConnectAuth + token), ResultReceiver
_ssl.pony -- SSLContextFactory (shared SSL context creation)
json_requester.pony -- JsonRequester actor (GET/POST/PATCH with JSON response)
no_content_requester.pony -- NoContentRequester actor (DELETE/PUT expecting 204)
check_requester.pony -- CheckRequester actor (GET returning Bool: 204=true, 404=false)
request_error.pony -- RequestError (status, response_body, message)
json.pony -- JsonConverter interface, JsonTypeString utility
query_params.pony -- QueryParams (URL query string builder with percent-encoding)
Expand All @@ -78,7 +77,7 @@ All API operations return `Promise[(T | RequestError)]`. The flow is:
1. Operation primitive (e.g., `GetRepository`) creates a `Promise`
2. Creates a `ResultReceiver[T]` actor with the promise and a `JsonConverter[T]`
3. Builds URL using `ponylang/uri` RFC 6570 template expansion for path parameters
4. Issues HTTP request via `JsonRequester` / `HTTPPost` / `HTTPPatch` / `HTTPDelete` / `HTTPPut` / `HTTPCheck`
4. Creates a short-lived request actor (`JsonRequester` / `NoContentRequester` / `CheckRequester` / `LinkedJsonRequester`) that owns an `HTTPClientConnection` from `ponylang/courier`
5. On success, JSON is parsed and converted to model via `JsonConverter`
6. Promise is fulfilled with either the model or a `RequestError`

Expand All @@ -102,7 +101,7 @@ Models have methods that chain to further API calls:

### Auth

`Credentials` holds a `TCPConnectAuth` and an optional token string. `RequestFactory` sets `User-Agent`, `Accept: application/vnd.github.v3+json`, and `Authorization: token <token>` headers.
`Credentials` holds a `lori.TCPConnectAuth` and an optional token string. Each request actor sets `User-Agent`, `Accept: application/vnd.github.v3+json`, and `Authorization: Bearer <token>` headers.

## Conventions

Expand All @@ -115,7 +114,7 @@ Models have methods that chain to further API calls:

## Known TODOs in Code

1. Potential HTTP GET duplication with paginated variant (paginated_list.pony)
None currently tracked.

## GitHub REST API Coverage Comparison

Expand Down
4 changes: 2 additions & 2 deletions corral.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"version": "0.1.0"
},
{
"locator": "github.com/ponylang/http.git",
"version": "0.6.4"
"locator": "github.com/ponylang/courier.git",
"version": "0.1.0"
},
{
"locator": "github.com/ponylang/json-ng.git",
Expand Down
4 changes: 2 additions & 2 deletions examples/create-gist-oo/main.pony
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use "../../github_rest_api"
use "../../github_rest_api/request"
use "cli"
use "net"
use lori = "lori"

actor Main
new create(env: Env) =>
Expand Down Expand Up @@ -42,7 +42,7 @@ actor Main
let token = cmd.option("token").string()

// ----- Create gist
let auth = TCPConnectAuth(env.root)
let auth = lori.TCPConnectAuth(env.root)
let creds = Credentials(auth, token)

let files = recover val
Expand Down
4 changes: 2 additions & 2 deletions examples/create-gist/main.pony
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use "../../github_rest_api"
use "../../github_rest_api/request"
use "cli"
use "net"
use lori = "lori"

actor Main
new create(env: Env) =>
Expand Down Expand Up @@ -42,7 +42,7 @@ actor Main
let token = cmd.option("token").string()

// ----- Create gist
let auth = TCPConnectAuth(env.root)
let auth = lori.TCPConnectAuth(env.root)
let creds = Credentials(auth, token)

let files = recover val
Expand Down
4 changes: 2 additions & 2 deletions examples/create-issue-comment-oo/main.pony
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use "../../github_rest_api"
use "../../github_rest_api/request"
use "cli"
use "net"
use lori = "lori"
use "promises"

actor Main
Expand Down Expand Up @@ -39,7 +39,7 @@ actor Main
let token = cmd.option("token").string()

// ----- Create issue comment
let auth = TCPConnectAuth(env.root)
let auth = lori.TCPConnectAuth(env.root)
let creds = Credentials(auth, token)

GitHub(creds).get_repo(owner, repo)
Expand Down
4 changes: 2 additions & 2 deletions examples/create-issue-comment/main.pony
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use "../../github_rest_api"
use "../../github_rest_api/request"
use "cli"
use "net"
use lori = "lori"

actor Main
new create(env: Env) =>
Expand Down Expand Up @@ -38,7 +38,7 @@ actor Main
let token = cmd.option("token").string()

// ----- Create issue comment
let auth = TCPConnectAuth(env.root)
let auth = lori.TCPConnectAuth(env.root)
let creds = Credentials(auth, token)

let p = CreateIssueComment(owner, repo, issue, comment, creds)
Expand Down
4 changes: 2 additions & 2 deletions examples/create-label-oo/main.pony
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use "../../github_rest_api"
use "../../github_rest_api/request"
use "cli"
use "net"
use lori = "lori"
use "promises"

actor Main
Expand Down Expand Up @@ -43,7 +43,7 @@ actor Main
let token = cmd.option("token").string()

// ----- Create issue comment
let auth = TCPConnectAuth(env.root)
let auth = lori.TCPConnectAuth(env.root)
let creds = Credentials(auth, token)

GitHub(creds).get_repo(owner, repo)
Expand Down
4 changes: 2 additions & 2 deletions examples/create-label/main.pony
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use "../../github_rest_api"
use "../../github_rest_api/request"
use "cli"
use "net"
use lori = "lori"

actor Main
new create(env: Env) =>
Expand Down Expand Up @@ -42,7 +42,7 @@ actor Main
let token = cmd.option("token").string()

// ----- Create issue comment
let auth = TCPConnectAuth(env.root)
let auth = lori.TCPConnectAuth(env.root)
let creds = Credentials(auth, token)

let p = CreateLabel(owner, repo, name, creds, color, description)
Expand Down
4 changes: 2 additions & 2 deletions examples/create-release-oo/main.pony
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use "../../github_rest_api"
use "../../github_rest_api/request"
use "cli"
use "net"
use lori = "lori"
use "promises"

actor Main
Expand Down Expand Up @@ -41,7 +41,7 @@ actor Main
let token = cmd.option("token").string()

// ----- Create release
let auth = TCPConnectAuth(env.root)
let auth = lori.TCPConnectAuth(env.root)
let creds = Credentials(auth, token)

GitHub(creds).get_repo(owner, repo)
Expand Down
4 changes: 2 additions & 2 deletions examples/create-release/main.pony
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use "../../github_rest_api"
use "../../github_rest_api/request"
use "cli"
use "net"
use lori = "lori"

actor Main
new create(env: Env) =>
Expand Down Expand Up @@ -40,7 +40,7 @@ actor Main
let token = cmd.option("token").string()

// ----- Create release
let auth = TCPConnectAuth(env.root)
let auth = lori.TCPConnectAuth(env.root)
let creds = Credentials(auth, token)

CreateRelease(owner, repo, tag_name, name, body, creds)
Expand Down
4 changes: 2 additions & 2 deletions examples/delete-label-oo/main.pony
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use "../../github_rest_api"
use "../../github_rest_api/request"
use "cli"
use "net"
use lori = "lori"
use "promises"

actor Main
Expand Down Expand Up @@ -39,7 +39,7 @@ actor Main
let token = cmd.option("token").string()

// ----- Create issue comment
let auth = TCPConnectAuth(env.root)
let auth = lori.TCPConnectAuth(env.root)
let creds = Credentials(auth, token)

GitHub(creds).get_repo(owner, repo)
Expand Down
4 changes: 2 additions & 2 deletions examples/delete-label/main.pony
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use "../../github_rest_api"
use "../../github_rest_api/request"
use "cli"
use "net"
use lori = "lori"

actor Main
new create(env: Env) =>
Expand Down Expand Up @@ -38,7 +38,7 @@ actor Main
let token = cmd.option("token").string()

// ----- Create issue comment
let auth = TCPConnectAuth(env.root)
let auth = lori.TCPConnectAuth(env.root)
let creds = Credentials(auth, token)

DeleteLabel(owner, repo, name, creds)
Expand Down
4 changes: 2 additions & 2 deletions examples/get-commit-oo/main.pony
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use "../../github_rest_api"
use "../../github_rest_api/request"
use "cli"
use "net"
use lori = "lori"
use "promises"

actor Main
Expand Down Expand Up @@ -39,7 +39,7 @@ actor Main
let token = cmd.option("token").string()

// ----- Get commit
let auth = TCPConnectAuth(env.root)
let auth = lori.TCPConnectAuth(env.root)
let creds = Credentials(auth, token)

GitHub(creds).get_repo(owner, repo)
Expand Down
4 changes: 2 additions & 2 deletions examples/get-commit/main.pony
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use "../../github_rest_api"
use "../../github_rest_api/request"
use "cli"
use "net"
use lori = "lori"

actor Main
new create(env: Env) =>
Expand Down Expand Up @@ -38,7 +38,7 @@ actor Main
let token = cmd.option("token").string()

// ----- Get commit
let auth = TCPConnectAuth(env.root)
let auth = lori.TCPConnectAuth(env.root)
let creds = Credentials(auth, token)

let p = GetCommit(owner, repo, sha, creds)
Expand Down
4 changes: 2 additions & 2 deletions examples/get-gist-oo/main.pony
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use "../../github_rest_api"
use "../../github_rest_api/request"
use "cli"
use "net"
use lori = "lori"

actor Main
new create(env: Env) =>
Expand Down Expand Up @@ -34,7 +34,7 @@ actor Main
let token = cmd.option("token").string()

// ----- Get gist
let auth = TCPConnectAuth(env.root)
let auth = lori.TCPConnectAuth(env.root)
let creds = Credentials(auth, token)

GitHub(creds).get_gist(gist_id)
Expand Down
4 changes: 2 additions & 2 deletions examples/get-gist/main.pony
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use "../../github_rest_api"
use "../../github_rest_api/request"
use "cli"
use "net"
use lori = "lori"

actor Main
new create(env: Env) =>
Expand Down Expand Up @@ -34,7 +34,7 @@ actor Main
let token = cmd.option("token").string()

// ----- Get gist
let auth = TCPConnectAuth(env.root)
let auth = lori.TCPConnectAuth(env.root)
let creds = Credentials(auth, token)

let p = GetGist(gist_id, creds)
Expand Down
4 changes: 2 additions & 2 deletions examples/get-issue-comments-oo/main.pony
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use "../../github_rest_api"
use "../../github_rest_api/request"
use "cli"
use "net"
use lori = "lori"
use "promises"

actor Main
Expand Down Expand Up @@ -39,7 +39,7 @@ actor Main
let token = cmd.option("token").string()

// ----- Get issue comments
let auth = TCPConnectAuth(env.root)
let auth = lori.TCPConnectAuth(env.root)
let creds = Credentials(auth, token)

GitHub(creds).get_repo(owner, repo)
Expand Down
4 changes: 2 additions & 2 deletions examples/get-issue-comments/main.pony
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use "../../github_rest_api"
use "../../github_rest_api/request"
use "cli"
use "net"
use lori = "lori"

actor Main
new create(env: Env) =>
Expand Down Expand Up @@ -38,7 +38,7 @@ actor Main
let token = cmd.option("token").string()

// ----- Get issue comments
let auth = TCPConnectAuth(env.root)
let auth = lori.TCPConnectAuth(env.root)
let creds = Credentials(auth, token)

let p = GetIssueComments(owner, repo, issue, creds)
Expand Down
Loading