From d5a1726235c9a67743b6c08a1be4d0bce2aa7425 Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Thu, 16 Aug 2018 14:50:16 -0400 Subject: [PATCH] added some more comments about how the routing table works (#1233) * added some more comments about how the routing table works * changed the comment slightly to pass an api test --- generators/newapp/templates/actions/app.go.tmpl | 10 ++++++++++ go.mod | 5 +++++ go.sum | 11 +++++++++++ 3 files changed, 26 insertions(+) diff --git a/generators/newapp/templates/actions/app.go.tmpl b/generators/newapp/templates/actions/app.go.tmpl index c3ab984c0..29ff441ac 100644 --- a/generators/newapp/templates/actions/app.go.tmpl +++ b/generators/newapp/templates/actions/app.go.tmpl @@ -36,6 +36,16 @@ var T *i18n.Translator // App is where all routes and middleware for buffalo // should be defined. This is the nerve center of your // application. +// +// Routing, middleware, groups, etc... are declared TOP -> DOWN. +// This means if you add a middleware to `app` *after* declaring a +// group, that group will NOT have that new middleware. The same +// is true of resource declarations as well. +// +// It also means that routes are checked in the order they are declared. +// `ServeFiles` is a CATCH-ALL route, so it should always be +// placed last in the route declarations, as it will prevent routes +// declared after it to never be called. func App() *buffalo.App { if app == nil { app = buffalo.New(buffalo.Options{ diff --git a/go.mod b/go.mod index 34bcc6d81..5a5479d74 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,7 @@ require ( github.com/gobuffalo/buffalo-plugins v0.0.0-20180814223854-e5520399f772 github.com/gobuffalo/buffalo-pop v0.0.0-20180814222253-a3af4d9a974c // indirect github.com/gobuffalo/envy v1.6.3 + github.com/gobuffalo/fizz v1.0.8 // indirect github.com/gobuffalo/github_flavored_markdown v1.0.0 github.com/gobuffalo/makr v1.1.2 github.com/gobuffalo/mw-basicauth v0.0.0-20180802152105-15d67c4ac152 @@ -26,6 +27,7 @@ require ( github.com/gobuffalo/shoulders v0.0.0-20180815165021-5569039eac2f github.com/gobuffalo/tags v2.0.8+incompatible github.com/gobuffalo/uuid v2.0.2+incompatible + github.com/gobuffalo/validate v2.0.1+incompatible // indirect github.com/gobuffalo/x v0.0.0-20180117215853-11ca13c05abd github.com/gorilla/context v1.1.1 github.com/gorilla/mux v1.6.2 @@ -46,7 +48,10 @@ require ( github.com/spf13/viper v1.1.0 github.com/stretchr/testify v1.2.2 golang.org/x/crypto v0.0.0-20180808211826-de0752318171 + golang.org/x/net v0.0.0-20180816102801-aaf60122140d // indirect golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f + golang.org/x/sys v0.0.0-20180816055513-1c9583448a9c // indirect + golang.org/x/tools v0.0.0-20180816002632-9de19001913f // indirect gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect gopkg.in/mail.v2 v2.0.0-20180731213649-a0242b2233b4 diff --git a/go.sum b/go.sum index e1a85d775..fbf3588de 100644 --- a/go.sum +++ b/go.sum @@ -31,6 +31,8 @@ github.com/gobuffalo/envy v1.6.3 h1:I9iyNACF0Tovfta7iqLrUAXFHYBDBWveQrjpEv2XeWs= github.com/gobuffalo/envy v1.6.3/go.mod h1:gOxUQY+OEwqH1a2m25Sqax1GIhj31tPNOIdFzj8QThs= github.com/gobuffalo/fizz v1.0.7 h1:xvG4eDlZvwzFq1cUk13VsveNNBHAIxOBDYBW3MGCLtg= github.com/gobuffalo/fizz v1.0.7/go.mod h1:fbtmvB0dcsGJUxM/S8biqkQtvykqPQGdkcg94zVu8GA= +github.com/gobuffalo/fizz v1.0.8 h1:17u36rzFc4KnCZZh/rpowY4YwZzKLdaR/GDCRehyMJw= +github.com/gobuffalo/fizz v1.0.8/go.mod h1:fbtmvB0dcsGJUxM/S8biqkQtvykqPQGdkcg94zVu8GA= github.com/gobuffalo/flect v0.0.0-20180728145722-2949e73d74b0/go.mod h1:B1X1r2SsFPE8Idc2OCoc+/eGmiknyq6oWDXLAYzRFLE= github.com/gobuffalo/genny v0.0.0-20180814214027-0379aef007c4/go.mod h1:YJRycuRm8LB7p9IM7SEQaVPlm8THfdrHaDZndVBjBzU= github.com/gobuffalo/github_flavored_markdown v1.0.0 h1:e2dK+SoHgOc/vfXuYMdXwEg2vAUlFzp8SBRwTOXckQ0= @@ -68,11 +70,14 @@ github.com/gobuffalo/shoulders v0.0.0-20180815165021-5569039eac2f/go.mod h1:6BOi github.com/gobuffalo/tags v2.0.6+incompatible/go.mod h1:9XmhOkyaB7UzvuY4UoZO4s67q8/xRMVJEaakauVQYeY= github.com/gobuffalo/tags v2.0.8+incompatible h1:ja3eo0Gnp6rTcoLK43zLPPKwuFVf/VXuDp0Svk8FSDo= github.com/gobuffalo/tags v2.0.8+incompatible/go.mod h1:B2OuqVIntUiwfvr8G95aA63VofxRmFBpP/yui2Mza6U= +github.com/gobuffalo/uuid v0.0.0-20180810195722-82924465e062/go.mod h1:K1sWc56g4/eeeQxLEPdNW22nZSRq59ih6YKnxGUZQRA= github.com/gobuffalo/uuid v2.0.0+incompatible/go.mod h1:ErhIzkRhm0FtRuiE/PeORqcw4cVi1RtSpnwYrxuvkfE= github.com/gobuffalo/uuid v2.0.2+incompatible h1:i67VLu/Y3F2Gis3bj9oWlggNu5ypD726OUVUyx8j99o= github.com/gobuffalo/uuid v2.0.2+incompatible/go.mod h1:K1sWc56g4/eeeQxLEPdNW22nZSRq59ih6YKnxGUZQRA= github.com/gobuffalo/validate v2.0.0+incompatible h1:KllrOhUUzAeTil8MaaQorZOH0Bx6KOvi8mRVlwFHRA4= github.com/gobuffalo/validate v2.0.0+incompatible/go.mod h1:N+EtDe0J8252BgfzQUChBgfd6L93m9weay53EWFVsMM= +github.com/gobuffalo/validate v2.0.1+incompatible h1:kAH2aizLUcFa0k5TkWNJZGgWGGdYRxTo7aogXXRSbZE= +github.com/gobuffalo/validate v2.0.1+incompatible/go.mod h1:JUiXzPhWPJhzqoQjARUkSoeTOTI0vy12dhTiAG+mCtk= github.com/gobuffalo/x v0.0.0-20180117215853-11ca13c05abd h1:0AiAe/jaKqMCar/zjOQFewW33iOLsCD6lPbqYlTcr2Q= github.com/gobuffalo/x v0.0.0-20180117215853-11ca13c05abd/go.mod h1:WevpGD+5YOreDJznWevcn8NTmQEW5STSBgIkpkjzqXc= github.com/golang/protobuf v1.1.0 h1:0iH4Ffd/meGoXqF2lSAhZHt8X+cPgkfn/cb6Cce5Vpc= @@ -100,6 +105,7 @@ github.com/joho/godotenv v1.2.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqx github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.2/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/lib/pq v0.0.0-20180523175426-90697d60dd84 h1:it29sI2IM490luSc3RAhp5WuCYnc6RtbfLVAB7nmC5M= @@ -200,14 +206,19 @@ golang.org/x/net v0.0.0-20180801234040-f4c29de78a2a/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20180808004115-f9ce57c11b24/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180811021610-c39426892332 h1:efGso+ep0DjyCBJPjvoz0HI6UldX4Md2F1rZFe1ir0E= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180816102801-aaf60122140d h1:211XH5RPVP5tOBkz6xm3/b7KxtjqVf6PYG+evqJpE08= +golang.org/x/net v0.0.0-20180816102801-aaf60122140d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180616030259-6c888cc515d3/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180814072032-4e1fef560951 h1:VfGaXvV9wRnTJreeGDE0FWEDiQP1WWUDmutCjCThDz8= golang.org/x/sys v0.0.0-20180814072032-4e1fef560951/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180816055513-1c9583448a9c h1:uHnKXcvx6SNkuwC+nrzxkJ+TpPwZOtumbhWrrOYN5YA= +golang.org/x/sys v0.0.0-20180816055513-1c9583448a9c/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20180813205110-a434f64ace81/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180816002632-9de19001913f/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= google.golang.org/appengine v1.1.0 h1:igQkv0AAhEIvTEpD5LIpAfav2eeVO9HBTjvKHVJPRSs= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= gopkg.in/airbrake/gobrake.v2 v2.0.9 h1:7z2uVWwn7oVeeugY1DtlPAy5H+KYgB1KeKTnqjNatLo=