Skip to content

Commit

Permalink
[Code] Pushing forwardx code
Browse files Browse the repository at this point in the history
  • Loading branch information
virenpawar committed Aug 4, 2020
1 parent bc48b27 commit 8e3a032
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@

# Dependency directories (remove the comment below to include it)
# vendor/


.idea
22 changes: 22 additions & 0 deletions forwardx/main.go
Original file line number Diff line number Diff line change
@@ -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()))
}

0 comments on commit 8e3a032

Please sign in to comment.