mirror of
https://github.com/mrusme/neonmodem.git
synced 2024-12-04 14:46:37 -05:00
Implemented #1 for Lemmy
This commit is contained in:
parent
71c86c4a56
commit
60a5162b5c
@ -3,8 +3,10 @@ package lemmy
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/mrusme/neonmodem/models/author"
|
"github.com/mrusme/neonmodem/models/author"
|
||||||
"github.com/mrusme/neonmodem/models/forum"
|
"github.com/mrusme/neonmodem/models/forum"
|
||||||
@ -100,14 +102,38 @@ func (sys *System) Description() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (sys *System) Load() error {
|
func (sys *System) Load() error {
|
||||||
|
var httpClient *http.Client = nil
|
||||||
|
var httpTransport *http.Transport = nil
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
url := sys.config["url"]
|
u := sys.config["url"]
|
||||||
if url == nil {
|
if u == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
sys.client, err = lemmy.New(url.(string))
|
proxy := sys.config["proxy"].(string)
|
||||||
|
if proxy != "" {
|
||||||
|
proxyURL, err := url.Parse(proxy)
|
||||||
|
if err != nil {
|
||||||
|
sys.logger.Error(err)
|
||||||
|
} else {
|
||||||
|
sys.logger.Debugf("setting up http proxy transport: %s\n", proxyURL.String())
|
||||||
|
httpTransport = &http.Transport{
|
||||||
|
Proxy: http.ProxyURL(proxyURL),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
httpClient = &http.Client{
|
||||||
|
Transport: httpTransport,
|
||||||
|
Timeout: time.Second * 10,
|
||||||
|
}
|
||||||
|
|
||||||
|
sys.client, err = lemmy.NewWithClient(
|
||||||
|
u.(string),
|
||||||
|
httpClient,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user