turbolinks

package module
v0.0.0-...-7fcc37e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

README

Turbolinks middleware for Go.

Usage

Use it as you would any HTTP middleware.

package main

import (
	"net/http"

	"github.com/bentranter/go-turbolinks"
)

func main() {
	mux := http.NewServeMux()

	mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		w.Write([]byte("Hello, world!"))
    })

	http.ListenAndServe(":3000", turbolinks.Middleware(mux))
}

See also the runnable example under the examples directory.

Dependencies

turbolinks depends on github.com/gorilla/securecookie.

Documentation

Index

Constants

View Source
const (
	// TurbolinksReferrer is the header sent by the Turbolinks frontend on any
	// XHR requests powered by Turbolinks. We use this header to detect if the
	// current request was sent from Turbolinks.
	TurbolinksReferrer = "Turbolinks-Referrer"

	// TurbolinksLocation is the name of the session key and cookie that we
	// use to handle redirect requests correctly.
	//
	// We name it `_turbolinks_location` to be consistent with the name Rails
	// gives to their session key and cookie that serves the same purpose.
	TurbolinksLocation = "_turbolinks_location"
)

Variables

This section is empty.

Functions

func Middleware

func Middleware(h http.Handler) http.Handler

Middleware wraps an HTTP handler to support the behaviour required by the Turbolinks JavaScript library.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL