Skip to content

xcltapestry/minisrv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

minsrv

MiniSrv is a thin wrapper around Go's HTTP server

http server:

func main() {
    minisrv.NewHTTPServer().
    AddRoute(route).
    AddMiddleware(middleware).
    ListenAndServe() // or ListenAndServe(":8082")
}

Route

// mux route
func route(m *mux.Router) {
    m.HandleFunc("/", indexHandler)
    m.HandleFunc("/health", healthHandler)
    m.HandleFunc("/api/v1/actid/%d", func(w http.ResponseWriter, req *http.Request) {
        fmt.Fprintf(w, "Welcome to the actid page!")
    })
}

Middeleware

func middleware(n *negroni.Negroni) {
    n.Use(negroni.HandlerFunc(Authorizer))
    n.Use(negroni.HandlerFunc(APIMiddleware))
}

Thanks

package type
https://github.com/gorilla/mux Route
https://github.com/urfave/negroni Middeleware

About

MiniSrv is a thin wrapper around Go's HTTP server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages