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

Commit

Permalink
v0.16.19 (#2076)
Browse files Browse the repository at this point in the history
* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

* Task updating formam (#2025)

* v0.16.13 (#2019)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* updating formam

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* Fixes #1987 and #2023 (#2026)

* v0.16.13 (#2019)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* fixing #1987 and #2023

* adding missing converstion

* removing commented code

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* changing version number

* moving to latest 2 go versions (#2038)

* Task binding cleanup (#2039)

* moving to latest 2 go versions

* cleaning up the decoder on the binding package

* Task update formam (#2041)

* v0.16.14 (#2030)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

* Task updating formam (#2025)

* v0.16.13 (#2019)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* updating formam

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* Fixes #1987 and #2023 (#2026)

* v0.16.13 (#2019)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* fixing #1987 and #2023

* adding missing converstion

* removing commented code

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* changing version number

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* updates formam version #2040

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* updating flect versionm (#2042)

* updating version

* updating some libraries to pass the github security warnings (#2044)

* Removing Grifts folder (#2050)

* removing the grifts folder

* removing grifts folder from codeclimate exceptions

* fixes the non-existing .git folder case (#2053)

* calling persist explicitly (#2054)

* adding version number

* Pointing README to new go docs link

* running packr2

* Warns if response is attempted to be written twice (#2059)

* v0.16.16 (#2055)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

* Task updating formam (#2025)

* v0.16.13 (#2019)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* updating formam

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* Fixes #1987 and #2023 (#2026)

* v0.16.13 (#2019)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* fixing #1987 and #2023

* adding missing converstion

* removing commented code

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* changing version number

* moving to latest 2 go versions (#2038)

* Task binding cleanup (#2039)

* moving to latest 2 go versions

* cleaning up the decoder on the binding package

* Task update formam (#2041)

* v0.16.14 (#2030)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

* Task updating formam (#2025)

* v0.16.13 (#2019)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* updating formam

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* Fixes #1987 and #2023 (#2026)

* v0.16.13 (#2019)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* fixing #1987 and #2023

* adding missing converstion

* removing commented code

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* changing version number

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* updates formam version #2040

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* updating flect versionm (#2042)

* updating version

* updating some libraries to pass the github security warnings (#2044)

* Removing Grifts folder (#2050)

* removing the grifts folder

* removing grifts folder from codeclimate exceptions

* fixes the non-existing .git folder case (#2053)

* calling persist explicitly (#2054)

* adding version number

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* only writing the header if it has not been written

* bumping version

* adding packr2 files

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* allows to specify custom partialfeeders

* cleaning up a bit for codeclimate

* changing the version

* Application Route Namer (#2075)

* Development (#2072)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

* Task updating formam (#2025)

* v0.16.13 (#2019)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* updating formam

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* Fixes #1987 and #2023 (#2026)

* v0.16.13 (#2019)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* fixing #1987 and #2023

* adding missing converstion

* removing commented code

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* changing version number

* moving to latest 2 go versions (#2038)

* Task binding cleanup (#2039)

* moving to latest 2 go versions

* cleaning up the decoder on the binding package

* Task update formam (#2041)

* v0.16.14 (#2030)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

* Task updating formam (#2025)

* v0.16.13 (#2019)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* updating formam

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* Fixes #1987 and #2023 (#2026)

* v0.16.13 (#2019)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* fixing #1987 and #2023

* adding missing converstion

* removing commented code

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* changing version number

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* updates formam version #2040

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* updating flect versionm (#2042)

* updating version

* updating some libraries to pass the github security warnings (#2044)

* Removing Grifts folder (#2050)

* removing the grifts folder

* removing grifts folder from codeclimate exceptions

* fixes the non-existing .git folder case (#2053)

* calling persist explicitly (#2054)

* adding version number

* Pointing README to new go docs link

* running packr2

* Warns if response is attempted to be written twice (#2059)

* v0.16.16 (#2055)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

* Task updating formam (#2025)

* v0.16.13 (#2019)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* updating formam

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* Fixes #1987 and #2023 (#2026)

* v0.16.13 (#2019)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* fixing #1987 and #2023

* adding missing converstion

* removing commented code

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* changing version number

* moving to latest 2 go versions (#2038)

* Task binding cleanup (#2039)

* moving to latest 2 go versions

* cleaning up the decoder on the binding package

* Task update formam (#2041)

* v0.16.14 (#2030)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

* Task updating formam (#2025)

* v0.16.13 (#2019)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* updating formam

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* Fixes #1987 and #2023 (#2026)

* v0.16.13 (#2019)

* adding direct version on the docker build

* fixing plugin installation

* Fix npm's package.json permissions (#2005)

Changed created file permissions from 644 (`-w----r--`) to 0644 (`rw-r--r--`)

* Bump spf13/viper to v1.7.0 (#1999)

* bunping version

* changing version on dockerfile

* patch to fix the keywords check on new app

* removing unneeded append

* Task fixing html binder (#2016)

* binder was not wired

* packing

* adding new version number

* pulling the buffalo binary from gobinaries.com

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* fixing #1987 and #2023

* adding missing converstion

* removing commented code

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* changing version number

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* updates formam version #2040

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* updating flect versionm (#2042)

* updating version

* updating some libraries to pass the github security warnings (#2044)

* Removing Grifts folder (#2050)

* removing the grifts folder

* removing grifts folder from codeclimate exceptions

* fixes the non-existing .git folder case (#2053)

* calling persist explicitly (#2054)

* adding version number

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* only writing the header if it has not been written

* bumping version

* adding packr2 files

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* allows to specify custom partialfeeders

* cleaning up a bit for codeclimate

* changing the version

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* allowing apps to define their own route namers

* tweaking and packing

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>

* v0.16.19

Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: hackerman <[email protected]>
  • Loading branch information
3 people authored Jan 7, 2021
1 parent 4c0bda0 commit 48a5576
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 62 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ RUN npm install -g --no-progress yarn \
# Install golangci
RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.24.0
# Installing buffalo binary
RUN curl -sf https://gobinaries.com/gobuffalo/buffalo/[email protected].18 | sh
RUN curl -sf https://gobinaries.com/gobuffalo/buffalo/[email protected].19 | sh
RUN go get github.com/gobuffalo/buffalo-pop/v2
RUN buffalo version

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.slim.build
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN npm i -g --no-progress yarn \
&& yarn config set yarn-offline-mirror-pruning true

# Pulling docker binary from releases
RUN curl -sf https://gobinaries.com/gobuffalo/buffalo/[email protected].18 | sh
RUN curl -sf https://gobinaries.com/gobuffalo/buffalo/[email protected].19 | sh
RUN go get github.com/gobuffalo/buffalo-pop/v2
RUN buffalo version

Expand Down
6 changes: 6 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ type App struct {
root *App
children []*App
filepaths []string

// Routenamer for the app. This field provides the ability to override the
// base route namer for something more specific to the app.
RouteNamer RouteNamer
}

// Muxer returns the underlying mux router to allow
Expand All @@ -48,6 +52,8 @@ func New(opts Options) *App {
moot: &sync.RWMutex{},
routes: RouteList{},
children: []*App{},

RouteNamer: baseRouteNamer{},
}

dem := a.defaultErrorMiddleware
Expand Down
58 changes: 1 addition & 57 deletions route_mappings.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"strings"

"github.com/gobuffalo/envy"
"github.com/gobuffalo/flect"
"github.com/gobuffalo/flect/name"
"github.com/gorilla/handlers"
)
Expand Down Expand Up @@ -263,7 +262,7 @@ func (a *App) addRoute(method string, url string, h Handler) *RouteInfo {

url = path.Join(a.Prefix, url)
url = a.normalizePath(url)
name := a.buildRouteName(url)
name := a.RouteNamer.NameRoute(url)

hs := funcKey(h)
r := &RouteInfo{
Expand Down Expand Up @@ -291,61 +290,6 @@ func (a *App) addRoute(method string, url string, h Handler) *RouteInfo {
return r
}

//buildRouteName builds a route based on the path passed.
func (a *App) buildRouteName(p string) string {
if p == "/" || p == "" {
return "root"
}

resultParts := []string{}
parts := strings.Split(p, "/")

for index, part := range parts {

originalPart := parts[index]

var previousPart string
if index > 0 {
previousPart = parts[index-1]
}

var nextPart string
if len(parts) > index+1 {
nextPart = parts[index+1]
}

isIdentifierPart := strings.Contains(part, "{") && (strings.Contains(part, flect.Singularize(previousPart)))
isSimplifiedID := part == `{id}`

if isIdentifierPart || isSimplifiedID || part == "" {
continue
}

if strings.Contains(nextPart, "{") {
part = flect.Singularize(part)
}

if originalPart == "new" || originalPart == "edit" {
resultParts = append([]string{part}, resultParts...)
continue
}

if strings.Contains(previousPart, "}") {
resultParts = append(resultParts, part)
continue
}

resultParts = append(resultParts, part)
}

if len(resultParts) == 0 {
return "unnamed"
}

underscore := strings.TrimSpace(strings.Join(resultParts, "_"))
return name.VarCase(underscore)
}

func stripAsset(path string, h http.Handler, a *App) http.Handler {
if path == "" {
return h
Expand Down
74 changes: 74 additions & 0 deletions routenamer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package buffalo

import (
"strings"

"github.com/gobuffalo/flect"
"github.com/gobuffalo/flect/name"
)

// RouteNamer is in charge of naming a route from the
// path assigned, this name typically will be used if no
// name is assined with .Name(...).
type RouteNamer interface {
// NameRoute receives the path and returns the name
// for the route.
NameRoute(string) string
}

// BaseRouteNamer is the default route namer used by apps.
type baseRouteNamer struct{}

func (drn baseRouteNamer) NameRoute(p string) string {
if p == "/" || p == "" {
return "root"
}

resultParts := []string{}
parts := strings.Split(p, "/")

for index, part := range parts {

originalPart := parts[index]

var previousPart string
if index > 0 {
previousPart = parts[index-1]
}

var nextPart string
if len(parts) > index+1 {
nextPart = parts[index+1]
}

isIdentifierPart := strings.Contains(part, "{") && (strings.Contains(part, flect.Singularize(previousPart)))
isSimplifiedID := part == `{id}`

if isIdentifierPart || isSimplifiedID || part == "" {
continue
}

if strings.Contains(nextPart, "{") {
part = flect.Singularize(part)
}

if originalPart == "new" || originalPart == "edit" {
resultParts = append([]string{part}, resultParts...)
continue
}

if strings.Contains(previousPart, "}") {
resultParts = append(resultParts, part)
continue
}

resultParts = append(resultParts, part)
}

if len(resultParts) == 0 {
return "unnamed"
}

underscore := strings.TrimSpace(strings.Join(resultParts, "_"))
return name.VarCase(underscore)
}
4 changes: 2 additions & 2 deletions router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ func Test_buildRouteName(t *testing.T) {
a := New(Options{})

for input, result := range cases {
fResult := a.buildRouteName(input)
fResult := a.RouteNamer.NameRoute(input)
r.Equal(result, fResult, input)
}

Expand All @@ -751,7 +751,7 @@ func Test_buildRouteName(t *testing.T) {
}

for input, result := range cases {
fResult := a.buildRouteName(input)
fResult := a.RouteNamer.NameRoute(input)
r.Equal(result, fResult, input)
}
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package runtime

// Version is the current version of the buffalo binary
var Version = "v0.16.18"
var Version = "v0.16.19"

0 comments on commit 48a5576

Please sign in to comment.