Skip to content

Commit

Permalink
mdformat README.md */README.md.
Browse files Browse the repository at this point in the history
  • Loading branch information
sengi committed Oct 17, 2023
1 parent f8dfd64 commit cdab452
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 51 deletions.
33 changes: 16 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -70,31 +67,31 @@ 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` /
`go mod` commit.

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.

Expand All @@ -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
9 changes: 4 additions & 5 deletions trie/README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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
58 changes: 29 additions & 29 deletions triemux/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<anything>" will go to this backend).
mux.Handle("/com", true, com)
// Register a prefix route pointing to the "com" backend (all requests to
// "/com<anything>" 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

0 comments on commit cdab452

Please sign in to comment.