532278 (1) [Avatar] Offline
#1
server.go
[ 749 bytes ]
Hello,

Can somebody help me in my issues with manners. It seem to redirect all my request to home page and not on the correct url path. Setting nil to handler don;t work either, ith throws error. here is the code

package main

import (
"fmt"
"net/http"
"os"
"os/signal"

"github.com/braintree/manners"
)

type handler struct{}

func shutdownInterrupt(ch <-chan os.Signal) {
<-ch
manners.Close()
}

func hello(response http.ResponseWriter, request *http.Request) {
query := request.URL.Query()
name := query.Get("name")
fmt.Fprintf(response, "Hello %s", name)
}

func (h *handler) ServeHTTP(response http.ResponseWriter, request *http.Request) {
fmt.Fprintf(response, "Home Page!")
}

func newHandler() *handler {
return &handler{}
}

func main() {
ch := make(chan os.Signal)
handler := newHandler()

signal.Notify(ch, os.Interrupt, os.Kill)
go shutdownInterrupt(ch)

http.HandleFunc("/hello", hello)
manners.ListenAndServe(":8888", handler)

}