From 8e3a032ab94609d2ec9683e3b3a26bc41eccb90b Mon Sep 17 00:00:00 2001 From: Viren Pawar Date: Tue, 4 Aug 2020 18:27:18 +0530 Subject: [PATCH] [Code] Pushing forwardx code --- .gitignore | 3 +++ forwardx/main.go | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 forwardx/main.go diff --git a/.gitignore b/.gitignore index 66fd13c..be40f79 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,6 @@ # Dependency directories (remove the comment below to include it) # vendor/ + + +.idea \ No newline at end of file diff --git a/forwardx/main.go b/forwardx/main.go new file mode 100644 index 0000000..cbc3212 --- /dev/null +++ b/forwardx/main.go @@ -0,0 +1,22 @@ +package main + +import ( + "github.com/gorilla/mux" + "log" + "net/http" +) + +func NewRouter() *mux.Router { + r := mux.NewRouter().StrictSlash(true) + r.HandleFunc("/", Forwarder).Methods(http.MethodGet) + return r +} + +func Forwarder(w http.ResponseWriter, r *http.Request) { + q := r.URL.Query()["url"] + http.Redirect(w, r, q[0], http.StatusFound) +} + +func main() { + log.Fatal(http.ListenAndServe("0.0.0.0:88", NewRouter())) +}