Reusable framework for micro services & command line tools
Reusable framework for Go apps & command line tools
Create routing.go
with the following content:
package main
import (
"fmt"
"net/http"
"github.com/short-d/app/fw/router"
"github.com/short-d/app/fw/service"
)
func main() {
routes := []router.Route{
{
Method: http.MethodGet,
MatchPrefix: false,
Path: "/:name",
Handle: func(w http.ResponseWriter, r *http.Request, params router.Params) {
name := params["name"]
page := fmt.Sprintf(`<h1>Hello, %s!<h1>`, name)
w.Write([]byte(page))
},
},
}
routingService := service.
NewRoutingBuilder("Example").
Routes(routes).
Build()
routingService.StartAndWait(8080)
}
Start the service using this command:
go run routing.go
That’s it! You can now visit the web page at http://localhost:8080/Gopher!
app
When contributing to this repository, please first discuss the change you wish
to make via Slack channel with the owner
of this repository before making a change.
Please open a draft pull request when you are working on an issue so that the
owner knows it is in progress. The owner may take over or reassign the issue if no
body replies after ten days assigned to you.
Please join this Slack channel to
discuss bugs, dev environment setup, tooling, and coding best practices.
Harry Liu - byliuyang
This project is maintained under MIT license.