main.go 517 Bytes
Newer Older
Aksel Baardsen's avatar
fix  
Aksel Baardsen committed
1
2
3
4
5
package main

import (
	"fmt"
	"net/http"
Aksel Baardsen's avatar
works    
Aksel Baardsen committed
6
7

	"github.com/gorilla/mux"
Aksel Baardsen's avatar
fix  
Aksel Baardsen committed
8
9
10
11
)

func main() {

Aksel Baardsen's avatar
works    
Aksel Baardsen committed
12
13
14
	r := mux.NewRouter()
	r.HandleFunc("/", handlerHome)
	r.HandleFunc("/hello/{name}/{gahe}", handlerHome2)
Aksel Baardsen's avatar
fix  
Aksel Baardsen committed
15
16


Aksel Baardsen's avatar
works    
Aksel Baardsen committed
17
18
19
20
	http.Handle("/", r)
	http.ListenAndServe(":5000", nil)

}
Aksel Baardsen's avatar
fix  
Aksel Baardsen committed
21

Aksel Baardsen's avatar
works    
Aksel Baardsen committed
22
23
24
func handlerHome(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintln(w, "aiaiai")
}
Aksel Baardsen's avatar
fix  
Aksel Baardsen committed
25

Aksel Baardsen's avatar
works    
Aksel Baardsen committed
26
27
28
29
30
func handlerHome2(w http.ResponseWriter, r *http.Request) {
	vars := mux.Vars(r)
	w.WriteHeader(http.StatusOK)
	fmt.Fprintf(w, "Name: %v%v\n", vars["name"], vars["gahe"])
}