Categorygithub.com/kelchy/go-lib/http/server
modulepackage
0.1.1
Repository: https://github.com/kelchy/go-lib.git
Documentation: pkg.go.dev

# README

	// initialize with empty cors setting
        rtr := server.New([]string{})

	// sample custom middleware
        rtr.Use(func (next http.Handler) http.Handler {
                return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
                        next.ServeHTTP(w, r)
                })
        })

	// use "esc" to create a "codified" version of static files and declare like this
	// https://github.com/mjibson/esc
	// for example ~/go/bin/esc -o testdir/test.go -pkg static -ignore=".*.go" testdir
        rtr.StaticFs("/test/", static.FS(false))

	// api definition
        rtr.Get("/welcome", func(w http.ResponseWriter, r *http.Request) {
                server.JSON(w, r, map[string]string{
                        "status": "success",
                })
        })

	// run server with cleartext http/2
        rtr.Run("h2c", ":8080")

# Packages

No description provided by the author

# Functions

JSON - send a json response.
New - constructor function to initialize instance.
URLParam - return value of a url parameter.

# Structs

Router - initialized instance.

# Type aliases

ChiRouter - interface for chi router.