aboutsummaryrefslogtreecommitdiffsponsor
path: root/internal/service/service_json.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/service/service_json.go')
-rw-r--r--internal/service/service_json.go64
1 files changed, 0 insertions, 64 deletions
diff --git a/internal/service/service_json.go b/internal/service/service_json.go
deleted file mode 100644
index 571eb30..0000000
--- a/internal/service/service_json.go
+++ /dev/null
@@ -1,64 +0,0 @@
-package service
-
-import (
- "encoding/json"
- "net/url"
-)
-
-type JsonURL struct {
- *url.URL
-}
-
-func (m JsonURL) MarshalJSON() ([]byte, error) {
- str := m.String()
- return json.Marshal(str)
-}
-
-func (m *JsonURL) UnmarshalJSON(buf []byte) error {
- var str string
-
- err := json.Unmarshal(buf, &str)
- if err != nil {
- return err
- }
-
- m.URL, err = url.Parse(str)
- return err
-}
-
-func (m Mirror) MarshalJSON() ([]byte, error) {
- type Alias Mirror
-
- m2 := struct {
- *Alias
- From JsonURL `json:"from"`
- To JsonURL `json:"to"`
- }{
- Alias: (*Alias)(&m),
- From: JsonURL{m.From},
- To: JsonURL{m.To},
- }
-
- return json.Marshal(m2)
-}
-
-func (m *Mirror) UnmarshalJSON(buf []byte) error {
- type Alias Mirror
-
- var m2 struct {
- *Alias
- From JsonURL `json:"from"`
- To JsonURL `json:"to"`
- }
-
- m2.Alias = (*Alias)(m)
- err := json.Unmarshal(buf, &m2)
- if err != nil {
- return err
- }
-
- m.From = m2.From.URL
- m.To = m2.To.URL
-
- return nil
-}