VividCortex / siesta

Composable framework for writing HTTP handlers in Go.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

uriPath does not work with http.FileServer?

dvliman opened this issue · comments

Is my understanding correct that uriPath is not a 'pattern' where it ends / map to just 1 HandlerFunc?
func (s *Service) Route(.., uriPath, ...)

as a result, siesta.Service.Route does not really behave like http.Handle / http.HandleFunc?

package main

import (
        "net/http"
)

func main() {
        http.Handle("/", http.FileServer(http.Dir("static")))
        http.ListenAndServe(":3000", nil)
}

ah looks like it is not a pattern. I should call service.Register() so that it adds to the DefaultServeMux and have http.Handle function register my static path.

I'd be happy to write a documentation for this if necessary.

Yes, you'll have to either call service.Register() or simply pass service as the handler, e.g. http.ListenAndServe(":3000", service).

Please feel free to add documentation and submit a pull request.