dustin / go-coap

Implementation of CoAP in go.
MIT License
342 stars 103 forks source link

coap.ServeMux does not support root path ("/") handler #41

Open palsivertsen opened 7 years ago

palsivertsen commented 7 years ago

Adding a handler with path "/" will result in a "http: invalid pattern " panic:

package main

import (
    "log"
    "net"

    "github.com/dustin/go-coap"
)

func main() {
    mux := coap.NewServeMux()
    mux.Handle("/", coap.FuncHandler(handler))
    log.Fatal(coap.ListenAndServe("udp", ":5683", mux))
}

func handler(l *net.UDPConn, a *net.UDPAddr, m *coap.Message) *coap.Message {
    log.Printf("%s-%d: %b", a.String(), m.MessageID, m.Payload)
    return nil
}