Skip to content

Commit 0aed521

Browse files
author
allan
committed
first commit gobard
1 parent 153d208 commit 0aed521

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed

configuration/configuration.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package configuration
2+
3+
import "github.com/caarlos0/env/v6"
4+
5+
type Configuration struct {
6+
IsDebug bool `env:"IS_DEBUG"`
7+
BaseUrl string
8+
//RestClient *resty.Client
9+
}
10+
11+
func GetConfiguration() *Configuration {
12+
configuration := Configuration{}
13+
err := env.Parse(&configuration)
14+
if err != nil {
15+
panic("failed to read configuration")
16+
}
17+
//
18+
//configuration.BaseUrl = routes.BASE_URL
19+
//
20+
return &configuration
21+
}

go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module github.com/Allan-Nava/go-bard
2+
3+
go 1.19
4+
5+
require (
6+
github.com/caarlos0/env/v6 v6.10.1 // indirect
7+
github.com/go-resty/resty/v2 v2.7.0 // indirect
8+
golang.org/x/net v0.0.0-20211029224645-99673261e6eb // indirect
9+
gopkg.in/validator.v2 v2.0.1 // indirect
10+
)

go.sum

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
github.com/caarlos0/env/v6 v6.10.1 h1:t1mPSxNpei6M5yAeu1qtRdPAK29Nbcf/n3G7x+b3/II=
2+
github.com/caarlos0/env/v6 v6.10.1/go.mod h1:hvp/ryKXKipEkcuYjs9mI4bBCg+UI0Yhgm5Zu0ddvwc=
3+
github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY=
4+
github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I=
5+
golang.org/x/net v0.0.0-20211029224645-99673261e6eb h1:pirldcYWx7rx7kE5r+9WsOXPXK0+WH5+uZ7uPmJ44uM=
6+
golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
7+
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
8+
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
9+
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
10+
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
11+
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
12+
gopkg.in/validator.v2 v2.0.1 h1:xF0KWyGWXm/LM2G1TrEjqOu4pa6coO9AlWSf3msVfDY=
13+
gopkg.in/validator.v2 v2.0.1/go.mod h1:lIUZBlB3Im4s/eYp39Ry/wkR02yOPhZ9IwIRBjuPuG8=

gobard/gobard.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package gobard
2+
3+
import (
4+
"github.com/Allan-Nava/go-bard/configuration"
5+
"github.com/go-resty/resty/v2"
6+
)
7+
8+
type IGoBard interface {
9+
}
10+
11+
type gobard struct {
12+
configuration *configuration.Configuration
13+
restClient *resty.Client
14+
}
15+
16+
func NewFakeYou(configuration *configuration.Configuration) IGoBard {
17+
fk := &gobard{
18+
configuration: configuration,
19+
}
20+
fk.restClient = resty.New()
21+
//fk.restClient.SetBaseURL(routes.BASE_URL)
22+
/*
23+
fk.restClient.SetHeader("Referer", "https://bard.google.com/")
24+
//"Host": "bard.google.com",
25+
//"X-Same-Domain": "1",
26+
//"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36",
27+
//"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
28+
//"Origin": "https://bard.google.com",
29+
//"Referer": "https://bard.google.com/",
30+
*/
31+
fk.restClient.SetHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8")
32+
fk.restClient.SetHeader("Host", "bard.google.com")
33+
fk.restClient.SetHeader("X-Same-Domain", "1")
34+
fk.restClient.SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36")
35+
fk.restClient.SetHeader("Origin", "https://bard.google.com")
36+
if configuration.IsDebug {
37+
fk.restClient.SetDebug(true)
38+
}
39+
return fk
40+
}

0 commit comments

Comments
 (0)