GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — interpose/examples/secure/main.go at master · carbocation/interpose

Expand file tree

/

main.go

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
38 lines (31 loc) · 1.01 KB
/

main.go

Copy path

File metadata and controls

38 lines (31 loc) · 1.01 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"fmt"
"net/http"
"time"
"github.com/carbocation/interpose"
"github.com/gorilla/mux"
"github.com/stretchr/graceful"
"github.com/unrolled/secure"
)
func main() {
mw := interpose.New()
// Use unrolled's secure framework
// If you inspect the headers, you will see X-Frame-Options set to DENY
// Must be called before the router because it modifies HTTP headers
secureMiddleware := secure.New(secure.Options{
FrameDeny: true,
})
mw.Use(secureMiddleware.Handler)
// Apply the router. By adding it first, all of our other middleware will be
// executed before the router, allowing us to modify headers before any
// output has been generated.
router := mux.NewRouter()
mw.UseHandler(router)
router.HandleFunc("/{user}", func(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, "Welcome to the home page, %s!", mux.Vars(req)["user"])
})
// Launch and permit graceful shutdown, allowing up to 10 seconds for existing
// connections to end
graceful.Run(":3001", 10*time.Second, mw)
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.