Skip to content

Instantly share code, notes, and snippets.

View aavrug's full-sized avatar
🏃‍♂️
Focusing

Gaurav Kumar aavrug

🏃‍♂️
Focusing
View GitHub Profile
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)
package main
import (
"log"
cfg "./config"
)
var configfile = flag.String("config", "config.json", "config file path")
func main() {
// Config.go
package config
import (
"encoding/json"
"io/ioutil"
)
func init() {
cfg = new(Config)
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)
}
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)
}
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)
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
)
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)
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
)
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)
}