mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-06-30 10:30:44 +02:00
style: using effective go and refactoring
This commit is contained in:
@ -4,15 +4,12 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"time"
|
||||
)
|
||||
|
||||
|
||||
// Fetch fetches the NIP-11 RelayInformationDocument.
|
||||
func Fetch(ctx context.Context, u string) (info *RelayInformationDocument, err error) {
|
||||
if _, ok := ctx.Deadline(); !ok {
|
||||
@ -47,6 +44,7 @@ func Fetch(ctx context.Context, u string) (info *RelayInformationDocument, err e
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
info = &RelayInformationDocument{}
|
||||
dec := json.NewDecoder(resp.Body)
|
||||
err = dec.Decode(info)
|
||||
|
Reference in New Issue
Block a user