README.md
1[![GoDoc](https://godoc.org/code.as/writeas/go-webfinger?status.svg)](https://godoc.org/code.as/writeas/go-webfinger)
2
3# go-webfinger
4
5go-webfinger is a golang webfinger server implementation. See [v1.0](https://github.com/writeas/go-webfinger/releases/tag/1.0) for the latest stable version, and our [Code.as repo](https://code.as/writeas/go-webfinger) for the Write.as-specific implementation.
6
7Past v1.0, this fork was made especially for federation support on [Write.as](https://write.as), which includes users across write.as, \*.writeas.com, and custom domains we host. The `master` branch contains changes specific to our implementation, and will change without notification.
8
9## Usage
10
11`webfinger.Service` is implemented as a net/http handler, which means
12usage is simply registering the object with your http service.
13
14Using the webfinger service as the main ServeHTTP:
15
16```go
17myResolver = ...
18wf := webfinger.Default(myResolver{})
19wf.NotFoundHandler = // the rest of your app
20http.ListenAndService(":8080", wf)
21```
22
23Using the webfinger service as a route on an existing HTTP router:
24
25```go
26myResolver = ...
27wf := webfinger.Default(myResolver{})
28http.Handle(webfinger.WebFingerPath, http.HandlerFunc(wf.Webfinger))
29http.ListenAndService(":8080", nil)
30```
31
32## Defaults
33
34The webfinger service is installed with a few defaults. Some of these
35defaults ensure we stick closely to the webfinger specification (tls-only, CORS, Content-Type)
36and other defaults are simply useful for development (no-cache)
37
38The full list of defaults can be found in the godoc for `webfinger.Service`. They are exposed
39as public variables which can be overriden.
40
41`PreHandlers` are the list of preflight HTTP handlers to run. You can add your own via `wf.PreHandlers["my-custom-name"] = ...`, however,
42execution order is not guaranteed.
43
44### TLS-Only
45
46Handler which routes to the TLS version of the page. Disable via `wf.NoTLSHandler = nil`.
47
48### No-Cache
49
50A PreFlight handler which sets no-cache headers on anything under `/.well-known/webfinger`. Disable or override via `wf.PreHandlers[webfinger.NoCacheMiddleware]`
51
52### Content Type as application/jrd+json
53
54A PreFlight handler which sets the Content-Type to `application/jrd+json`. Disable or override via `wf.PreHandlers[webfinger.ContentTypeMiddleware]`.
55
56### CORS
57
58A PreFlight handler which adds the CORS headers. Disable or override via `wf.PreHandlers[webfinger.CorsMiddleware].`
59