ip/resolver: move decoders into sub package
This commit is contained in:
parent
7c2ad9384b
commit
a0fa688451
3 changed files with 7 additions and 6 deletions
|
|
@ -1,11 +1,11 @@
|
|||
package resolver
|
||||
package decoder
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
)
|
||||
|
||||
func JsonipDecoder(r io.Reader) ([]byte, error) {
|
||||
func Jsonip(r io.Reader) ([]byte, error) {
|
||||
var v struct {
|
||||
Ip string `json:"ip"`
|
||||
Location string `json:"geo-ip"`
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package resolver
|
||||
package decoder
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
)
|
||||
|
||||
func MyIPDecoder(r io.Reader) ([]byte, error) {
|
||||
func MyIP(r io.Reader) ([]byte, error) {
|
||||
var v struct {
|
||||
Ip string `json:"ip"`
|
||||
Country string `json:"country"`
|
||||
|
|
@ -3,6 +3,7 @@ package resolver
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
"dnsupdater/ip/resolver/decoder"
|
||||
httpres "dnsupdater/ip/resolver/http"
|
||||
)
|
||||
|
||||
|
|
@ -25,7 +26,7 @@ func init() {
|
|||
Provide(&httpres.Service{
|
||||
ServiceName: "jsonip",
|
||||
Url: "https://jsonip.com",
|
||||
Decoder: JsonipDecoder,
|
||||
Decoder: decoder.Jsonip,
|
||||
})
|
||||
|
||||
Provide(&httpres.Service{
|
||||
|
|
@ -59,6 +60,6 @@ func init() {
|
|||
Provide(&httpres.Service{
|
||||
ServiceName: "myip",
|
||||
Url: "https://api.myip.com",
|
||||
Decoder: MyIPDecoder,
|
||||
Decoder: decoder.MyIP,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue