Add a basic server router to main
This commit is contained in:
parent
9deda4b3fb
commit
5377e42e71
3 changed files with 22 additions and 2 deletions
20
main.go
20
main.go
|
@ -1,7 +1,23 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Printf("Hello World")
|
||||
router := mux.NewRouter().StrictSlash(true)
|
||||
|
||||
router.HandleFunc("/", HandleRoot)
|
||||
|
||||
if err := http.ListenAndServe(":8080", router); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func HandleRoot(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, "Hello World")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue