This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func requestHandler(w http.ResponseWriter, r *http.Request) { | |
| if r.Method == http.MethodGet { | |
| resp := sendRequest(w, r) | |
| fmt.Println(resp) | |
| fmt.Println(reflect.TypeOf(resp)) | |
| var dat map[string]interface{} | |
| if err := json.Unmarshal(resp, &dat); err != nil { | |
| panic(err) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "log" | |
| cfg "./config" | |
| ) | |
| var configfile = flag.String("config", "config.json", "config file path") | |
| func main() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Config.go | |
| package config | |
| import ( | |
| "encoding/json" | |
| "io/ioutil" | |
| ) | |
| func init() { | |
| cfg = new(Config) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func sendRequest(w http.ResponseWriter, r *http.Request) { | |
| url := r.URL | |
| url.Host = "todo.api.iriiis.com" | |
| var buf bytes.Buffer | |
| tee := io.TeeReader(r.Body, &buf) | |
| proxyReq, err := http.NewRequest(r.Method, "https:"+url.String(), tee) | |
| if err != nil { | |
| fmt.Println(err) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func sendRequest(w http.ResponseWriter, r *http.Request) { | |
| url := r.URL | |
| url.Host = "example.com" | |
| var buf bytes.Buffer | |
| tee := io.TeeReader(r.Body, &buf) | |
| fmt.Println(buf.String()) | |
| proxyReq, err := http.NewRequest(r.Method, "https:"+url.String(), tee) | |
| if err != nil { | |
| fmt.Println(err) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func sendRequest(w http.ResponseWriter, r *http.Request) { | |
| url := r.URL | |
| url.Host = "example.com" | |
| proxyReq, err := http.NewRequest(r.Method, "https:"+url.String(), r.Body) | |
| if err != nil { | |
| fmt.Println(err) | |
| } | |
| proxyReq.Header.Set("Host", r.Host) | |
| proxyReq.Header.Set("X-Forwarded-For", r.RemoteAddr) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "encoding/json" | |
| "fmt" | |
| "io/ioutil" | |
| "log" | |
| "net/http" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func sendRequest(w http.ResponseWriter, r *http.Request) { | |
| url := r.URL | |
| url.Host = "example.com" | |
| proxyReq, err := http.NewRequest(r.Method, "https:"+url.String(), r.Body) | |
| if err != nil { | |
| fmt.Println(err) | |
| } | |
| proxyReq.Header.Set("Host", r.Host) | |
| proxyReq.Header.Set("X-Forwarded-For", r.RemoteAddr) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "encoding/json" | |
| "fmt" | |
| "io/ioutil" | |
| "log" | |
| "net/http" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func sendRequest(w http.ResponseWriter, r *http.Request) { | |
| url := r.URL | |
| url.Host = "https://example.com/" | |
| fmt.Println(url.String()) | |
| proxyReq, err := http.NewRequest(r.Method, url.String(), r.Body) | |
| if err != nil { | |
| fmt.Println(err) | |
| } |
NewerOlder