From f29175fb661b83ef81c82ba4b84736f7e6abb021 Mon Sep 17 00:00:00 2001 From: michaellindman Date: Fri, 5 Jul 2019 16:47:28 +0100 Subject: [PATCH] moved api to options --- api.go | 11 +++++------ data.go | 12 ++++-------- file.go | 10 ---------- 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/api.go b/api.go index a652570..88611b5 100755 --- a/api.go +++ b/api.go @@ -60,12 +60,11 @@ func Request(path string) ([]byte, *logger.HTTPError) { return nil, logger.HTTPErr(http.StatusInternalServerError) } - head, er := Header() - if er != nil { - return nil, er - } - for _, headers := range head.Headers { - req.Header.Set(headers.Name, headers.Value) + req.Header.Set("Accept", "application/json") + req.Header.Set("Content-Type", "application/json") + ap := Option().Options + for _, api := range ap.API { + req.Header.Set(api.Name, api.Value) } client := &http.Client{Timeout: time.Second * 10} diff --git a/data.go b/data.go index c10bf6a..c5d3251 100644 --- a/data.go +++ b/data.go @@ -4,14 +4,6 @@ import ( "time" ) -// Headers API request headers -type Headers struct { - Headers []struct { - Name string `json:"name"` - Value string `json:"value"` - } `json:"headers"` -} - // Options main program options type Options struct { Title string `json:"title"` @@ -24,6 +16,10 @@ type Options struct { DynamicReload bool `json:"DynamicReload"` BaseDir string `json:"BaseDir"` } `json:"ace"` + API []struct { + Name string `json:"name"` + Value string `json:"value"` + } `json:"api"` } `json:"options"` Database struct { Server string `json:"server"` diff --git a/file.go b/file.go index ef4d79c..f928113 100644 --- a/file.go +++ b/file.go @@ -22,16 +22,6 @@ func File(path string) ([]byte, *logger.HTTPError) { return byteValue, nil } -// Header get header data from json file -func Header() (headers *Headers, err *logger.HTTPError) { - resp, err := File("./assets/json/headers.json") - if err != nil { - return - } - json.Unmarshal(resp, &headers) - return -} - // Option get options data from json file func Option() (options *Options) { resp, err := File("./assets/json/options.json")