Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 52bdbec89a | |||
| 57129fcb83 | |||
| eda8018886 |
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
[](https://git.the-red-comet.org/guy176251/go-reddit/actions)
|
[](https://git.the-red-comet.org/guy176251/go-reddit/actions)
|
||||||
[](https://goreportcard.com/report/git.the-red-comet.org/guy176251/go-reddit)
|
[](https://goreportcard.com/report/git.the-red-comet.org/guy176251/go-reddit)
|
||||||
[](https://pkg.go.dev/git.the-red-comet.org/guy176251/go-reddit/v2/reddit)
|
[](https://pkg.go.dev/git.the-red-comet.org/guy176251/reddit-go/reddit)
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -27,13 +27,13 @@ You can view Reddit's official API documentation [here](https://www.reddit.com/d
|
|||||||
To get a specific version from the list of [versions](https://git.the-red-comet.org/guy176251/go-reddit/releases):
|
To get a specific version from the list of [versions](https://git.the-red-comet.org/guy176251/go-reddit/releases):
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
go get git.the-red-comet.org/guy176251/go-reddit/v2@vX.Y.Z
|
go get git.the-red-comet.org/guy176251/reddit-go@vX.Y.Z
|
||||||
```
|
```
|
||||||
|
|
||||||
Or for the latest version:
|
Or for the latest version:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
go get git.the-red-comet.org/guy176251/go-reddit/v2
|
go get git.the-red-comet.org/guy176251/reddit-go
|
||||||
```
|
```
|
||||||
|
|
||||||
The repository structure for managing multiple major versions follows the one outlined [here](https://github.com/go-modules-by-example/index/tree/master/016_major_version_repo_strategy#major-branch-strategy).
|
The repository structure for managing multiple major versions follows the one outlined [here](https://github.com/go-modules-by-example/index/tree/master/016_major_version_repo_strategy#major-branch-strategy).
|
||||||
@@ -45,7 +45,7 @@ Make sure to have a Reddit app with a valid client id and secret. [Here](https:/
|
|||||||
```go
|
```go
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "git.the-red-comet.org/guy176251/go-reddit/v2/reddit"
|
import "git.the-red-comet.org/guy176251/reddit-go/reddit"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
credentials := reddit.Credentials{ID: "id", Secret: "secret", Username: "username", Password: "password"}
|
credentials := reddit.Credentials{ID: "id", Secret: "secret", Username: "username", Password: "password"}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"git.the-red-comet.org/guy176251/go-reddit/v2/reddit"
|
"git.the-red-comet.org/guy176251/reddit-go/reddit"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ctx = context.Background()
|
var ctx = context.Background()
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"git.the-red-comet.org/guy176251/go-reddit/v2/reddit"
|
"git.the-red-comet.org/guy176251/reddit-go/reddit"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ctx = context.Background()
|
var ctx = context.Background()
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"git.the-red-comet.org/guy176251/go-reddit/v2/reddit"
|
"git.the-red-comet.org/guy176251/reddit-go/reddit"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ctx = context.Background()
|
var ctx = context.Background()
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"git.the-red-comet.org/guy176251/go-reddit/v2/reddit"
|
"git.the-red-comet.org/guy176251/reddit-go/reddit"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Post struct {
|
type Post struct {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.the-red-comet.org/guy176251/go-reddit/v2/reddit"
|
"git.the-red-comet.org/guy176251/reddit-go/reddit"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ctx = context.Background()
|
var ctx = context.Background()
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"git.the-red-comet.org/guy176251/go-reddit/v2/reddit"
|
"git.the-red-comet.org/guy176251/reddit-go/reddit"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ctx = context.Background()
|
var ctx = context.Background()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
module git.the-red-comet.org/guy176251/go-reddit
|
module git.the-red-comet.org/guy176251/reddit-go
|
||||||
|
|
||||||
go 1.24.0
|
go 1.24.0
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -25,7 +25,7 @@ const (
|
|||||||
libraryVersion = "2.0.0"
|
libraryVersion = "2.0.0"
|
||||||
|
|
||||||
defaultBaseURL = "https://oauth.reddit.com"
|
defaultBaseURL = "https://oauth.reddit.com"
|
||||||
defaultBaseURLReadonly = "https://reddit.com"
|
defaultBaseURLReadonly = "https://old.reddit.com"
|
||||||
defaultTokenURL = "https://www.reddit.com/api/v1/access_token"
|
defaultTokenURL = "https://www.reddit.com/api/v1/access_token"
|
||||||
|
|
||||||
mediaTypeJSON = "application/json"
|
mediaTypeJSON = "application/json"
|
||||||
@@ -349,7 +349,7 @@ func parseRate(r *http.Response) Rate {
|
|||||||
// pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface,
|
// pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface,
|
||||||
// the raw response will be written to v, without attempting to decode it.
|
// the raw response will be written to v, without attempting to decode it.
|
||||||
func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Response, error) {
|
func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Response, error) {
|
||||||
slog.Debug("Making API request to reddit", "url", req.URL.String(), "method", req.Method)
|
slog.Debug("Making API request to reddit", "url", req.URL.String(), "method", req.Method, "headers", req.Header)
|
||||||
if err := c.checkRateLimitBeforeDo(req); err != nil {
|
if err := c.checkRateLimitBeforeDo(req); err != nil {
|
||||||
return &Response{
|
return &Response{
|
||||||
Response: err.Response,
|
Response: err.Response,
|
||||||
|
|||||||
Reference in New Issue
Block a user