Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New HTTP router implementation for start-api.
This change takes a lot of the logic out of start.go for HTTP handling, and moves it to a new, separate 'router' package. It also moves all of the environment handling out into a separate file (env.go and env_test.go), to make that a lot cleaner and remove duplication. These changes makes for a much smaller start.go, with far less logic. The new HTTP router implementation looks like this: ``` // initiate a new router r := router.NewServerlessRouter() // Add a AWS::Serverless::Function to it r.AddFunction(someServerlessFunction) // Add a AWS::Serverless::Api to it r.AddAPI(someServerlessApi) // Add a static files dir r.AddStaticDir("public/", "/") // Pass it to Go's HTTP pkg for serving http.ListenAndServe("0.0.0.0:3000", r.Router())) ``` As the router impementation isn't a mega-method-of-doom anymore, it's much, much easier to unit test. I've included quite a few tests already.
- Loading branch information