mirror of
https://github.com/SphericalKat/medium.rip.git
synced 2026-10-21 01:34:22 +00:00
feat: add sample response.json for dev
Signed-off-by: Sphericalkat <amolele@gmail.com>
This commit is contained in:
1 parent
9600c21c5a
commit
848cd514d0
3 files changed
+35
-3
No files matched your search
@@ -2,15 +2,33 @@ package client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/medium.rip/internal/config"
|
||||
"github.com/medium.rip/pkg/entities"
|
||||
)
|
||||
|
||||
func PostData(postId string) (*entities.MediumResponse, error) {
|
||||
if config.Conf.Env == "dev" {
|
||||
file, err := os.ReadFile("response.json")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mr, err := entities.UnmarshalMediumResponse(file)
|
||||
if err != nil {
|
||||
log.Printf("Error unmarshalling body from response %v\n", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &mr, nil
|
||||
}
|
||||
|
||||
// http client to post data
|
||||
url := "https://medium.com/_/graphql"
|
||||
method := "POST"
|
||||
|
||||
Reference in new issue
Block a user