Compare commits

..

No commits in common. "13b3abbcabc85f15788387bbc3d4cb91c9a87fc4" and "20e2679dbd61cd485a78b04f48e44fd1d7145704" have entirely different histories.

4 changed files with 4 additions and 34 deletions

View File

@ -4,7 +4,6 @@ import (
"context" "context"
"fmt" "fmt"
"net/http" "net/http"
"sync" "sync"
"github.com/medium.rip/api/routes" "github.com/medium.rip/api/routes"
@ -33,10 +32,6 @@ func RegisterRoutes(ctx context.Context, wg *sync.WaitGroup, engine *html.Engine
Browse: config.Conf.Env == "dev", Browse: config.Conf.Env == "dev",
})) }))
if config.Conf.Proxy != "" {
log.Printf("Using proxy: %s", config.Conf.Proxy)
}
routes.RegisterRoutes(app) routes.RegisterRoutes(app)
go func(app *fiber.App) { go func(app *fiber.App) {

View File

@ -17,7 +17,6 @@ type Config struct {
S3Endpoint string `koanf:"S3_ENDPOINT"` S3Endpoint string `koanf:"S3_ENDPOINT"`
Env string `koanf:"ENV"` Env string `koanf:"ENV"`
SecretKey string `koanf:"SECRET_KEY"` SecretKey string `koanf:"SECRET_KEY"`
Proxy string `koanf:"PROXY"`
} }
var Conf *Config var Conf *Config

View File

@ -6,8 +6,6 @@ import (
"net/http" "net/http"
"os" "os"
"strings" "strings"
"net/url"
"crypto/tls"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
@ -32,35 +30,13 @@ func PostData(postId string) (*entities.MediumResponse, error) {
} }
// http client to post data // http client to post data
urlreq := "https://medium.com/_/graphql" url := "https://medium.com/_/graphql"
method := "POST" method := "POST"
payload := strings.NewReader(fmt.Sprintf("{\"query\":\"query {\\n post(id: \\\"%s\\\") {\\n title\\n createdAt\\n creator {\\n id\\n name\\n }\\n content {\\n bodyModel {\\n paragraphs {\\n name\\n text\\n type\\n href\\n layout\\n markups {\\n title\\n type\\n href\\n userId\\n start\\n end\\n anchorType\\n }\\n iframe {\\n mediaResource {\\n href\\n iframeSrc\\n iframeWidth\\n iframeHeight\\n }\\n }\\n metadata {\\n id\\n originalWidth\\n originalHeight\\n }\\n }\\n }\\n }\\n }\\n }\",\"variables\":{}}", postId)) payload := strings.NewReader(fmt.Sprintf("{\"query\":\"query {\\n post(id: \\\"%s\\\") {\\n title\\n createdAt\\n creator {\\n id\\n name\\n }\\n content {\\n bodyModel {\\n paragraphs {\\n name\\n text\\n type\\n href\\n layout\\n markups {\\n title\\n type\\n href\\n userId\\n start\\n end\\n anchorType\\n }\\n iframe {\\n mediaResource {\\n href\\n iframeSrc\\n iframeWidth\\n iframeHeight\\n }\\n }\\n metadata {\\n id\\n originalWidth\\n originalHeight\\n }\\n }\\n }\\n }\\n }\\n }\",\"variables\":{}}", postId))
//log.Printf("Article ID: %s", postId) client := &http.Client{}
//log.Printf("PAYLOAD: %s", payload) req, err := http.NewRequest(method, url, payload)
var client *http.Client
if config.Conf.Proxy != "" {
proxyURL, err := url.Parse(config.Conf.Proxy)
if err != nil {
panic(err)
}
client = &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyURL(proxyURL),
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
},
}
} else {
client = &http.Client{}
}
req, err := http.NewRequest(method, urlreq, payload)
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36")
if err != nil { if err != nil {
log.Printf("Error constructing request %v\n", err) log.Printf("Error constructing request %v\n", err)
return nil, err return nil, err