Skip to content
dadamssolutionsPublic

About

Adapters to add middleware to HTTP Handlers

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

30 Commits

Folders and files

Repository files navigation

adaptd

Go Report Card GoDoc

Adapters to add middleware to HTTP Handlers.

Installing

Use go get:

go get github.com/dadamssolutions/adaptd

Or, in go.mod:

require (
    github.com/dadamssolutions/adaptd
)

Examples

import (
    "net/http"
    "github.com/dadamssolutions/adaptd"
)

func main() {
    // Index handler should enure that HTTPS is used
    http.Handle("/", adaptd.EnsureHTTPS(false)(indexHandler))

    // Login handler should use HTTPS and handle GET and POST requests
    // Use Adapt to add multiple Adapters at once.
    // Be sure to check HTTPS first.
    loginHandler = adaptd.Adapt(loginHandler,
                    adaptd.EnsureHTTPS(false),
                    adaptd.GetAndOtherRequest(loginPostHandler, http.MethodPost))
    http.Handle("/login", loginHandler)

    http.ListenAndServeTLS(":8080", "cert.pem", "key.pem", nil)
}

Contributing

Submit a pull request.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments

About

Adapters to add middleware to HTTP Handlers

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages