Giter Site home page Giter Site logo

gohsts's Introduction

GoDoc

GoHsts Middleware

GoHsts is a simple middleware implementation that appends the HTTP Secure Transport Policy (HSTS) header to every response. Once the header has been added and a supporting browser has received the response, the browser will prevent any communications from being sent over HTTP to the specified domain and instead route any subsequent requests over HTTPS.

More information about HSTS can be found here

This middleware handler uses implements the Go http.Handler interface

Usage

go get github.com/donpisci/GoHsts

To instatiate the hstsHandler, use the provided constructor

hstsMiddleware := NewHstsHandler()

Using this constructor will set the structs fields to default values

There are two fields on the hstsHandler struct; MaxAge (int) and IncludeSubDomains (bool). The MaxAge field determines how long the header is valid for in seconds and by default is set to 31536000 (1 year) The IncludeSubDomains field does what it says on the tin. By default, this is set to true and is the recommended setting.

Once the values have been set, the HSTS middleware can be used like standard middleware:

http.ListenAndServe("/", hstsMiddleware.HstsHandlerFunc(otherMiddleware))

gohsts's People

Contributors

johnepiscopo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.