Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
StrictSlash should be customizable fixes #810
Browse files Browse the repository at this point in the history
  • Loading branch information
markbates committed Dec 21, 2017
1 parent ec4fab3 commit 6eb55f2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func New(opts Options) *App {
404: defaultErrorHandler,
500: defaultErrorHandler,
},
router: mux.NewRouter().StrictSlash(true),
router: mux.NewRouter().StrictSlash(!opts.LooseSlash),
moot: &sync.Mutex{},
routes: RouteList{},
children: []*App{},
Expand Down
18 changes: 14 additions & 4 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,29 @@ type Options struct {
// Addr is the bind address provided to http.Server. Default is "127.0.0.1:3000"
// Can be set using ENV vars "ADDR" and "PORT".
Addr string
// Host that this application will be available at. Default is "http://127.0.0.1:[$PORT|3000]".
Host string

// Env is the "environment" in which the App is running. Default is "development".
Env string

// LogLevel defaults to "debug".
LogLevel string
// Logger to be used with the application. A default one is provided.
Logger Logger

// MethodOverride allows for changing of the request method type. See the default
// implementation at buffalo.MethodOverride
MethodOverride http.HandlerFunc

// SessionStore is the `github.com/gorilla/sessions` store used to back
// the session. It defaults to use a cookie store and the ENV variable
// `SESSION_SECRET`.
SessionStore sessions.Store
// SessionName is the name of the session cookie that is set. This defaults
// to "_buffalo_session".
SessionName string
// Host that this application will be available at. Default is "http://127.0.0.1:[$PORT|3000]".
Host string

// Worker implements the Worker interface and can process tasks in the background.
// Default is "github.com/gobuffalo/worker.Simple.
Worker worker.Worker
Expand All @@ -55,8 +60,13 @@ type Options struct {
PreWares []PreWare

Context context.Context
cancel context.CancelFunc
Prefix string

// LooseSlash defines the trailing slash behavior for new routes. The initial value is false.
// This is the opposite of http://www.gorillatoolkit.org/pkg/mux#Router.StrictSlash
LooseSlash bool

cancel context.CancelFunc
Prefix string
}

// PreWare takes an http.Handler and returns and http.Handler
Expand Down

0 comments on commit 6eb55f2

Please sign in to comment.