| "regexp" | "regexp" | ||||
| "runtime" | "runtime" | ||||
| log "github.com/Sirupsen/logrus" | |||||
| "github.com/codegangsta/cli" | "github.com/codegangsta/cli" | ||||
| log "github.com/sirupsen/logrus" | |||||
| "github.com/goanywhere/cmd" | "github.com/goanywhere/cmd" | ||||
| "github.com/goanywhere/crypto" | "github.com/goanywhere/crypto" | ||||
| ) | ) | ||||
| const endpoint = "https://github.com/goanywhere/rex" | |||||
| const endpoint = "https://git.thevis.us/skepto/rex" | |||||
| var secrets = []rune("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*(-_+)") | var secrets = []rune("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*(-_+)") | ||||
| "runtime" | "runtime" | ||||
| "syscall" | "syscall" | ||||
| log "github.com/Sirupsen/logrus" | |||||
| "github.com/codegangsta/cli" | "github.com/codegangsta/cli" | ||||
| log "github.com/sirupsen/logrus" | |||||
| "github.com/goanywhere/rex/internal" | |||||
| "github.com/goanywhere/rex/livereload" | |||||
| "git.thevis.us/skepto/rex/internal" | |||||
| "git.thevis.us/skepto/rex/livereload" | |||||
| "git.thevis.us/skepto/env" | |||||
| "git.thevis.us/skepto/fs" | |||||
| "github.com/goanywhere/cmd" | "github.com/goanywhere/cmd" | ||||
| "github.com/goanywhere/env" | |||||
| "github.com/goanywhere/fs" | |||||
| ) | ) | ||||
| var ( | var ( |
| "net/http" | "net/http" | ||||
| "path/filepath" | "path/filepath" | ||||
| "github.com/goanywhere/env" | |||||
| "github.com/goanywhere/rex" | |||||
| "github.com/goanywhere/rex/livereload" | |||||
| "git.thevis.us/skepto/env" | |||||
| "git.thevis.us/skepto/rex" | |||||
| "git.thevis.us/skepto/rex/livereload" | |||||
| ) | ) | ||||
| type User struct { | type User struct { |
| "net/http/httptest" | "net/http/httptest" | ||||
| "testing" | "testing" | ||||
| "github.com/goanywhere/rex" | |||||
| "git.thevis.us/skepto/rex" | |||||
| . "github.com/smartystreets/goconvey/convey" | . "github.com/smartystreets/goconvey/convey" | ||||
| ) | ) | ||||
| "net/http/httptest" | "net/http/httptest" | ||||
| "testing" | "testing" | ||||
| "github.com/goanywhere/rex" | |||||
| "git.thevis.us/skepto/rex" | |||||
| . "github.com/smartystreets/goconvey/convey" | . "github.com/smartystreets/goconvey/convey" | ||||
| ) | ) | ||||
| "net/http/httptest" | "net/http/httptest" | ||||
| "testing" | "testing" | ||||
| "github.com/goanywhere/rex" | |||||
| "git.thevis.us/skepto/rex" | |||||
| . "github.com/smartystreets/goconvey/convey" | . "github.com/smartystreets/goconvey/convey" | ||||
| ) | ) | ||||
| "net/http" | "net/http" | ||||
| "time" | "time" | ||||
| "github.com/Sirupsen/logrus" | |||||
| "github.com/sirupsen/logrus" | |||||
| ) | ) | ||||
| // Logger renders the simple HTTP accesses logs for the upcoming http.Handler. | // Logger renders the simple HTTP accesses logs for the upcoming http.Handler. |
| "path" | "path" | ||||
| "testing" | "testing" | ||||
| "github.com/goanywhere/rex" | |||||
| "git.thevis.us/skepto/rex" | |||||
| . "github.com/smartystreets/goconvey/convey" | . "github.com/smartystreets/goconvey/convey" | ||||
| ) | ) | ||||
| "net/http" | "net/http" | ||||
| "path" | "path" | ||||
| "github.com/goanywhere/env" | |||||
| "github.com/goanywhere/fs" | |||||
| "git.thevis.us/skepto/env" | |||||
| "git.thevis.us/skepto/fs" | |||||
| ) | ) | ||||
| // Shortcut for string based map. | // Shortcut for string based map. |
| "sync" | "sync" | ||||
| "time" | "time" | ||||
| log "github.com/Sirupsen/logrus" | |||||
| "github.com/goanywhere/env" | |||||
| "git.thevis.us/skepto/env" | |||||
| "github.com/gorilla/mux" | "github.com/gorilla/mux" | ||||
| log "github.com/sirupsen/logrus" | |||||
| ) | ) | ||||
| var ( | var ( | ||||
| // Host creates a new application group under the given (sub)domain. | // Host creates a new application group under the given (sub)domain. | ||||
| func (self *server) Host(domain string) *server { | func (self *server) Host(domain string) *server { | ||||
| var middleware = new(middleware) | var middleware = new(middleware) | ||||
| self.mux.Host(domain).Handler(middleware) | |||||
| var mux = self.mux.Host(domain).Subrouter() | |||||
| self.mux.Host(domain).Handler(middleware) | |||||
| var mux = self.mux.Host(domain).Subrouter() | |||||
| server := &server{middleware: middleware, mux: mux} | server := &server{middleware: middleware, mux: mux} | ||||
| self.subservers = append(self.subservers, server) | self.subservers = append(self.subservers, server) |
| "path" | "path" | ||||
| "testing" | "testing" | ||||
| "github.com/goanywhere/env" | |||||
| mw "github.com/goanywhere/rex/middleware" | |||||
| "git.thevis.us/skepto/env" | |||||
| mw "git.thevis.us/skepto/rex/middleware" | |||||
| . "github.com/smartystreets/goconvey/convey" | . "github.com/smartystreets/goconvey/convey" | ||||
| ) | ) | ||||
| w.Header().Set("X-Powered-By", "base") | w.Header().Set("X-Powered-By", "base") | ||||
| }) | }) | ||||
| user := app.Host("localhost") | |||||
| user := app.Host("localhost") | |||||
| user.Get("/", func(w http.ResponseWriter, r *http.Request) { | user.Get("/", func(w http.ResponseWriter, r *http.Request) { | ||||
| w.Header().Set("X-Powered-By", "rex") | w.Header().Set("X-Powered-By", "rex") | ||||
| }) | }) | ||||
| Convey("rex.Host", t, func() { | Convey("rex.Host", t, func() { | ||||
| request, _ := http.NewRequest("GET", "http://localhost/", nil) | |||||
| request, _ := http.NewRequest("GET", "http://localhost/", nil) | |||||
| response := httptest.NewRecorder() | response := httptest.NewRecorder() | ||||
| app.ServeHTTP(response, request) | app.ServeHTTP(response, request) |