-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial bootstrap of resty documentation website (#1)
- Loading branch information
Showing
15 changed files
with
534 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
+++ | ||
date = '{{ .Date }}' | ||
draft = true | ||
title = '{{ replace .File.ContentBaseName "-" " " | title }}' | ||
+++ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.ml-20 { | ||
margin-left: 20px; | ||
} | ||
|
||
.book-brand { | ||
display: none; | ||
} | ||
|
||
.book-search { | ||
margin-top: 0; | ||
} | ||
|
||
.book-toc { | ||
font-size: .85rem; | ||
} | ||
|
||
.resty-badges { | ||
margin-top: 3rem; | ||
margin-bottom: 1rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
--- | ||
title: Welcome | ||
type: docs | ||
--- | ||
|
||
<p align="center"><img src="/img/resty-logo.svg" alt="Resty Logo" height="100px" width="225px" /></p> | ||
<p align="center" style="font-weight:bold">Simple HTTP, REST, and SSE client library for Go</p> | ||
<p align="center" class="resty-badges"><a href="https://github.com/go-resty/resty/actions/workflows/ci.yml?query=branch%3Amain"><img src="https://github.com/go-resty/resty/actions/workflows/ci.yml/badge.svg?branch=main" alt="Build Status"></a> <a href="https://app.codecov.io/gh/go-resty/resty/tree/v3"><img src="https://codecov.io/gh/go-resty/resty/branch/main/graph/badge.svg" alt="Code Coverage"></a> <a href="https://goreportcard.com/report/go-resty/resty"><img src="https://goreportcard.com/badge/go-resty/resty" alt="Go Report Card"></a> <a href="https://github.com/go-resty/resty/releases/latest"><img src="https://img.shields.io/badge/version-3.0.0-blue.svg" alt="Release Version"></a> <a href="https://pkg.go.dev/github.com/go-resty/resty/v3"><img src="https://pkg.go.dev/badge/github.com/go-resty/resty" alt="GoDoc"></a> <a href="LICENSE"><img src="https://img.shields.io/github/license/go-resty/resty.svg" alt="License"></a> <a href="https://github.com/avelino/awesome-go"><img src="https://awesome.re/mentioned-badge.svg" alt="Mentioned in Awesome Go"></a></p> | ||
</p> | ||
|
||
{{% columns %}} | ||
```go | ||
// HTTP, REST Client | ||
client := resty.New() | ||
defer client.Close() | ||
|
||
resp, err := client.R(). | ||
EnableTrace(). | ||
Get("https://httpbin.org/get") | ||
fmt.Println(err, resp) | ||
fmt.Println(resp.Request.TraceInfo()) | ||
``` | ||
<---> | ||
```go | ||
// SSE Client | ||
client := resty.NewSSE(). | ||
SetURL("https://sse.dev/test"). | ||
SetResultMapping("*", Message{}) | ||
|
||
client.Subscribe("*", func(v any) { | ||
msg := v.(*Message) | ||
fmt.Println(msg) | ||
}) | ||
``` | ||
|
||
{{% /columns %}} | ||
|
||
This website represents Resty v3 and above. For previous v2 documentation, refer to this [README.md](https://github.com/go-resty/resty/blob/v2/README.md "Resty v2 README") | ||
|
||
## Features | ||
|
||
{{% columns %}} | ||
* Simple and chainable methods | ||
* Multipart and Form data with ease | ||
* Request Path Params | ||
* Retry Mechanism | ||
* Goroutine & concurrent safe | ||
* Automatic decompresser (gzip, deflate) | ||
* Basic auth, Digest auth, Bearer, etc. | ||
* Request tracing | ||
* CURL command generation | ||
* HTTP/1.1 and HTTP/2. Integrate HTTP/3 | ||
|
||
|
||
<p class="ml-20">and much more ...</p> | ||
|
||
<---> | ||
|
||
* Automatic marshal and unmarshal | ||
* Large file upload and progress callback | ||
* Download to file | ||
* Redirect Policies | ||
* Debug mode with structured logging | ||
* Load Balancer and Service Discovery | ||
* Response body limit & Unlimited reads | ||
* Bazel support | ||
* Dynamic reload of TLS certificates | ||
* Custom root and client certificates | ||
|
||
<p class="ml-20">and much more ...</p> | ||
{{% /columns %}} | ||
|
||
## Highly Extensible | ||
|
||
Resty offers various ways to enhance its functionality by implementing its interfaces to meet all custom requirements. | ||
|
||
* Request & Response middleware | ||
* Content-Type encoder & decoder | ||
* Content Decompresser | ||
* Load Balancer and Service Discovery | ||
* Retry Strategy, Condition, and Hooks | ||
* Request Functions | ||
* Transport RoundTripper | ||
* Redirect Policy | ||
* Logger | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
title: "CURL Command Generation" | ||
--- | ||
|
||
# CURL Command Generation | ||
|
||
Resty provides a way to generate the CURL command in debug mode. | ||
|
||
{{% hint info %}} | ||
**NOTE:** Client-level settings can be overridden at the request level. | ||
{{% /hint %}} | ||
|
||
{{% hint warning %}} | ||
**NOTE:** | ||
|
||
- Potential to leak sensitive data from [Request]() and [Response]() in the debug log. | ||
- Beware of memory usage since the request body is reread. | ||
{{% /hint %}} | ||
|
||
## Methods | ||
* [Client.EnableGenerateCurlOnDebug]() | ||
* [Client.DisableGenerateCurlOnDebug]() | ||
* [Client.SetGenerateCurlOnDebug]() | ||
* [Request.EnableGenerateCurlOnDebug]() | ||
* [Request.DisableGenerateCurlOnDebug]() | ||
* [Request.SetGenerateCurlOnDebug]() | ||
|
||
```go | ||
client := resty.New() | ||
defer client.Close() | ||
|
||
resp, err := client.R(). | ||
EnableDebug(). | ||
EnableGenerateCurlOnDebug(). // This option works in conjunction with debug mode | ||
SetBody(map[string]string{ | ||
"name": "Alex", | ||
}). | ||
Post("https://httpbin.org/post") | ||
|
||
curlCmdExecuted := resp.Request.GenerateCurlCommand() | ||
fmt.Println(curlCmdExecuted) | ||
|
||
// Result: | ||
// curl -X POST -H 'Content-Type: application/json' -H 'User-Agent: go-resty/3.0.0 (https://resty.dev)' -d '{"name":"Alex"}' https://httpbin.org/post | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
--- | ||
title: "Request Path Params" | ||
weight: 1 | ||
--- | ||
|
||
# Request Path Params | ||
|
||
Resty provides easy-to-use dynamic request URL path params. It replaces the value of the key while composing the request URL. The value will be escaped using the [url.PathEscape](https://pkg.go.dev/net/url#PathEscape) function. | ||
|
||
{{% hint info %}} | ||
**NOTE:** Client-level settings can be overridden at the request level. | ||
{{% /hint %}} | ||
|
||
## Methods | ||
* [Client.SetPathParam]() | ||
* [Client.SetPathParams]() | ||
* [Request.SetPathParam]() | ||
* [Request.SetPathParams]() | ||
|
||
### Single Path Param | ||
```go | ||
client := resty.New() | ||
defer client.Close() | ||
|
||
client.R(). | ||
SetPathParam("userId", "[email protected]"). | ||
Get("/v1/users/{userId}/details") | ||
|
||
// Result: | ||
// /v1/users/[email protected]/details | ||
|
||
``` | ||
|
||
### Multiple Path Params | ||
```go | ||
client := resty.New() | ||
defer client.Close() | ||
|
||
client.R(). | ||
SetPathParams(map[string]string{ | ||
"userId": "[email protected]", | ||
"subAccountId": "100002", | ||
"path": "groups/developers", | ||
}). | ||
Get("/v1/users/{userId}/{subAccountId}/{path}/details) | ||
// Result: | ||
// /v1/users/[email protected]/100002/groups%2Fdevelopers/details | ||
``` | ||
# Request Raw Path Params | ||
Resty provides easy-to-use dynamic request URL **raw** path params. It replaces the value of the key while composing the request URL. The value used **as-is**, no escapes applied. | ||
## Methods | ||
* [Client.SetRawPathParam]() | ||
* [Client.SetRawPathParams]() | ||
* [Request.SetRawPathParam]() | ||
* [Request.SetRawPathParams]() | ||
### Single Raw Path Param | ||
```go | ||
client := resty.New() | ||
defer client.Close() | ||
client.R(). | ||
SetRawPathParam("path", "groups/developers"). | ||
Get("/v1/users/{userId}/details") | ||
// Result: | ||
// /v1/users/groups/developers/details | ||
``` | ||
### Multiple Raw Path Params | ||
```go | ||
client := resty.New() | ||
defer client.Close() | ||
client.R(). | ||
SetRawPathParams(map[string]string{ | ||
"userId": "sample@sample.com", | ||
"subAccountId": "100002", | ||
"path": "groups/developers", | ||
}). | ||
Get("/v1/users/{userId}/{subAccountId}/{path}/details") | ||
// Result: | ||
// /v1/users/[email protected]/100002/groups/developers/details | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
--- | ||
weight: 2 | ||
--- | ||
|
||
# Request Query Params | ||
|
||
Resty provides easy-to-add request query parameters into requests. | ||
|
||
Example: search=kitchen%20papers&size=large | ||
|
||
{{% hint info %}} | ||
**NOTE:** Client-level settings can be overridden at the request level. | ||
{{% /hint %}} | ||
|
||
## Methods | ||
* [Client.SetQueryParam]() | ||
* [Client.SetQueryParams]() | ||
* [Request.SetQueryParam]() | ||
* [Request.SetQueryParams]() | ||
* [Request.SetQueryParamsFromValues]() | ||
* [Request.SetQueryString]() | ||
|
||
### Single Query Param | ||
```go | ||
client := resty.New() | ||
defer client.Close() | ||
|
||
client.R(). | ||
SetQueryParam("search", "kitchen papers"). | ||
SetQueryParam("size", "large"). | ||
Get("/search") | ||
|
||
// Result: | ||
// /search?search=kitchen%20papers&size=large | ||
|
||
``` | ||
|
||
### Multiple Query Params | ||
```go | ||
client := resty.New() | ||
defer client.Close() | ||
|
||
client.R(). | ||
SetQueryParams(map[string]string{ | ||
"search": "kitchen papers", | ||
"size": "large", | ||
}). | ||
Get("/search") | ||
|
||
// Result: | ||
// /search?search=kitchen%20papers&size=large | ||
``` | ||
|
||
### Query Params from url.Values | ||
```go | ||
client := resty.New() | ||
defer client.Close() | ||
|
||
client.R(). | ||
SetQueryParamsFromValues(url.Values{ | ||
"status": []string{"pending", "approved", "open"}, | ||
}). | ||
Get("/search") | ||
|
||
// Result: | ||
// /search?status=pending&status=approved&status=open | ||
``` | ||
|
||
### Query Params from String | ||
```go | ||
client := resty.New() | ||
defer client.Close() | ||
|
||
client.R(). | ||
SetQueryString("productId=232&template=fresh-sample&cat=resty&source=google&kw=buy a lot more"). | ||
Get("/search") | ||
|
||
// Result: | ||
// /search?cat=resty&kw=buy+a+lot+more&productId=232&source=google&template=fresh-sample | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module github.com/go-resty/docs | ||
|
||
go 1.22.0 | ||
|
||
require github.com/alex-shpak/hugo-book v0.0.0-20241009212754-7c78a39c531a // indirect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github.com/alex-shpak/hugo-book v0.0.0-20241009212754-7c78a39c531a h1:GiRJQYc9Bt8H59/e0w/97i46Ql39CUIdDQjHikd9scA= | ||
github.com/alex-shpak/hugo-book v0.0.0-20241009212754-7c78a39c531a/go.mod h1:L4NMyzbn15fpLIpmmtDg9ZFFyTZzw87/lk7M2bMQ7ds= |
Oops, something went wrong.