1
0
Fork 0

ip/resolver: move decoders into sub package

This commit is contained in:
Henrik Hautakoski 2025-10-16 23:12:27 +02:00
parent 7c2ad9384b
commit a0fa688451
3 changed files with 7 additions and 6 deletions

View file

@ -1,11 +1,11 @@
package resolver package decoder
import ( import (
"encoding/json" "encoding/json"
"io" "io"
) )
func JsonipDecoder(r io.Reader) ([]byte, error) { func Jsonip(r io.Reader) ([]byte, error) {
var v struct { var v struct {
Ip string `json:"ip"` Ip string `json:"ip"`
Location string `json:"geo-ip"` Location string `json:"geo-ip"`

View file

@ -1,11 +1,11 @@
package resolver package decoder
import ( import (
"encoding/json" "encoding/json"
"io" "io"
) )
func MyIPDecoder(r io.Reader) ([]byte, error) { func MyIP(r io.Reader) ([]byte, error) {
var v struct { var v struct {
Ip string `json:"ip"` Ip string `json:"ip"`
Country string `json:"country"` Country string `json:"country"`

View file

@ -3,6 +3,7 @@ package resolver
import ( import (
"net/http" "net/http"
"dnsupdater/ip/resolver/decoder"
httpres "dnsupdater/ip/resolver/http" httpres "dnsupdater/ip/resolver/http"
) )
@ -25,7 +26,7 @@ func init() {
Provide(&httpres.Service{ Provide(&httpres.Service{
ServiceName: "jsonip", ServiceName: "jsonip",
Url: "https://jsonip.com", Url: "https://jsonip.com",
Decoder: JsonipDecoder, Decoder: decoder.Jsonip,
}) })
Provide(&httpres.Service{ Provide(&httpres.Service{
@ -59,6 +60,6 @@ func init() {
Provide(&httpres.Service{ Provide(&httpres.Service{
ServiceName: "myip", ServiceName: "myip",
Url: "https://api.myip.com", Url: "https://api.myip.com",
Decoder: MyIPDecoder, Decoder: decoder.MyIP,
}) })
} }