Created
March 27, 2017 20:45
-
-
Save jeffotoni/dea1baa29e11bf5fe6b3d22d033ee1e8 to your computer and use it in GitHub Desktop.
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
| /** @autor jeffotoni*/ | |
| package main | |
| import ( | |
| "fmt" | |
| "log" | |
| "net/http" | |
| "github.com/gorilla/mux" | |
| ) | |
| func main() { | |
| fmt.Println("Conect port : 4002") | |
| fmt.Println("Instance /register") | |
| ///create route | |
| router := mux.NewRouter().StrictSlash(true) | |
| router. | |
| HandleFunc("/register", func(w http.ResponseWriter, r *http.Request) { | |
| fmt.Println(r.Method) | |
| if r.Method == "POST" { | |
| Teste(w, r) | |
| } else if r.Method == "GET" { | |
| Teste2(w, r) | |
| } else { | |
| fmt.Fprintln(w, "pagina nao encontrada!") | |
| } | |
| }) | |
| // router.haHandleFunc("/register", Teste2). | |
| // Methods("POST") | |
| log.Fatal(http.ListenAndServe(":4002", router)) | |
| } | |
| func Teste(w http.ResponseWriter, r *http.Request) { | |
| fmt.Fprintln(w, "http teste ... ") | |
| } | |
| func Teste2(w http.ResponseWriter, r *http.Request) { | |
| fmt.Fprintln(w, "http teste 2... ") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment