From cdab452b4fc56b160957957603bfe8ba31430767 Mon Sep 17 00:00:00 2001 From: Chris Banks Date: Tue, 17 Oct 2023 13:23:44 +0100 Subject: [PATCH] mdformat README.md */README.md. --- README.md | 33 +++++++++++++-------------- trie/README.md | 9 ++++---- triemux/README.md | 58 +++++++++++++++++++++++------------------------ 3 files changed, 49 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index bbadb33c..5a99abbe 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,6 @@ loads a routing table into memory from a MongoDB database and: The sister project [`router-api`][router-api] provides a read/write interface to the underlying database. -[tm]: https://github.com/alphagov/router/tree/main/triemux -[router-api]: https://github.com/alphagov/router-api - ## Technical documentation Recommended reading: [How to Write Go Code](https://golang.org/doc/code.html) @@ -70,15 +67,15 @@ This project uses [Go Modules](https://github.com/golang/go/wiki/Modules) to ven 1. Update all the dependencies, including test dependencies, in your working copy: - ```sh - make update_deps - ``` + ```sh + make update_deps + ``` 1. Check for any errors and commit. - ```sh - git commit -- go.{mod,sum} vendor - ``` + ```sh + git commit -- go.{mod,sum} vendor + ``` 1. [Run the Router test suite](#run-the-test-suite). If you need to fix a failing test, keep your changes in separate commits to the `go get` / @@ -86,15 +83,15 @@ This project uses [Go Modules](https://github.com/golang/go/wiki/Modules) to ven 1. Run the tests for all dependencies: - ```sh - go test all - ``` + ```sh + go test all + ``` - - If there are failures, look into each one and determine whether it needs - fixing. - - If anything under `vendor/` needs changing then either raise a PR with - the upstream project or revert to a set of versions that work together. - Only `go get` and `go mod` should touch files in `vendor/`. + - If there are failures, look into each one and determine whether it needs + fixing. + - If anything under `vendor/` needs changing then either raise a PR with + the upstream project or revert to a set of versions that work together. + Only `go get` and `go mod` should touch files in `vendor/`. 1. Raise a PR. @@ -117,3 +114,5 @@ board](https://trello.com/b/u4FCzm53/). [MIT License](LICENCE) [#govuk-platform-engineering]: https://gds.slack.com/channels/govuk-platform-engineering +[router-api]: https://github.com/alphagov/router-api +[tm]: https://github.com/alphagov/router/tree/main/triemux diff --git a/trie/README.md b/trie/README.md index 45eb2d8f..2a4e70bb 100644 --- a/trie/README.md +++ b/trie/README.md @@ -1,7 +1,6 @@ -trie ----- +## trie -A minimal implementation of a [trie data structure][trie] for [Go][go]. Differs +A minimal implementation of a [trie data structure][trie] for [Go]. Differs from most implementations in that it uses string slices (`[]string`) as keys, rather than just strings. @@ -10,6 +9,6 @@ systems in general, rather than being specifically geared towards string lookup. Read the documentation on [godoc.org][docs] for details of how to use `trie`. -[trie]: https://en.wikipedia.org/wiki/Trie -[go]: http://golang.org [docs]: http://godoc.org/github.com/alphagov/router/trie +[go]: http://golang.org +[trie]: https://en.wikipedia.org/wiki/Trie diff --git a/triemux/README.md b/triemux/README.md index dfc489b2..5884bde1 100644 --- a/triemux/README.md +++ b/triemux/README.md @@ -1,5 +1,4 @@ -triemux -======= +# triemux `triemux` is an implementation of [Go]'s [`http.Handler`][handler] that multiplexes a set of other handlers onto a single path hierarchy, using an @@ -9,41 +8,42 @@ domain to be served by different applications. API documentation for `triemux` can be found at [godoc.org][docs]. -[handler]: https://pkg.go.dev/net/http#Handler -[Go]: https://go.dev/ -[docs]: https://pkg.go.dev/github.com/alphagov/router/triemux - -Install -------- +## Install - go install github.com/alphagov/router/triemux +``` +go install github.com/alphagov/router/triemux +``` -Usage ------ +## Usage - mux := triemux.NewMux() +``` +mux := triemux.NewMux() - com := httputil.NewSingleHostReverseProxy(url.Parse("https://example.com")) - org := httputil.NewSingleHostReverseProxy(url.Parse("https://example.org")) +com := httputil.NewSingleHostReverseProxy(url.Parse("https://example.com")) +org := httputil.NewSingleHostReverseProxy(url.Parse("https://example.org")) - // Register a prefix route pointing to the "com" backend (all requests to - // "/com" will go to this backend). - mux.Handle("/com", true, com) +// Register a prefix route pointing to the "com" backend (all requests to +// "/com" will go to this backend). +mux.Handle("/com", true, com) - // Register an exact (non-prefix) route pointing to the "org" backend. - mux.Handle("/org", false, org) +// Register an exact (non-prefix) route pointing to the "org" backend. +mux.Handle("/org", false, org) - ... +... - srv := &http.Server{ - Addr: ":8080", - Handler: mux, - ReadTimeout: 60 * time.Second(), - WriteTimeout: 60 * time.Second(), - } - srv.ListenAndServe() +srv := &http.Server{ + Addr: ":8080", + Handler: mux, + ReadTimeout: 60 * time.Second(), + WriteTimeout: 60 * time.Second(), +} +srv.ListenAndServe() +``` -Licence -------- +## Licence `triemux` is released under the MIT licence, a copy of which can be found in `LICENCE`. + +[docs]: https://pkg.go.dev/github.com/alphagov/router/triemux +[go]: https://go.dev/ +[handler]: https://pkg.go.dev/net/http#Handler