A golang webfinger server implementation
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 2.4 KiB

7 years ago
7 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. [![GoDoc](https://godoc.org/code.as/writeas/go-webfinger?status.svg)](https://godoc.org/code.as/writeas/go-webfinger)
  2. # go-webfinger
  3. go-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.
  4. Past 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.
  5. ## Usage
  6. `webfinger.Service` is implemented as a net/http handler, which means
  7. usage is simply registering the object with your http service.
  8. Using the webfinger service as the main ServeHTTP:
  9. ```go
  10. myResolver = ...
  11. wf := webfinger.Default(myResolver{})
  12. wf.NotFoundHandler = // the rest of your app
  13. http.ListenAndService(":8080", wf)
  14. ```
  15. Using the webfinger service as a route on an existing HTTP router:
  16. ```go
  17. myResolver = ...
  18. wf := webfinger.Default(myResolver{})
  19. http.Handle(webfinger.WebFingerPath, http.HandlerFunc(wf.Webfinger))
  20. http.ListenAndService(":8080", nil)
  21. ```
  22. ## Defaults
  23. The webfinger service is installed with a few defaults. Some of these
  24. defaults ensure we stick closely to the webfinger specification (tls-only, CORS, Content-Type)
  25. and other defaults are simply useful for development (no-cache)
  26. The full list of defaults can be found in the godoc for `webfinger.Service`. They are exposed
  27. as public variables which can be overriden.
  28. `PreHandlers` are the list of preflight HTTP handlers to run. You can add your own via `wf.PreHandlers["my-custom-name"] = ...`, however,
  29. execution order is not guaranteed.
  30. ### TLS-Only
  31. Handler which routes to the TLS version of the page. Disable via `wf.NoTLSHandler = nil`.
  32. ### No-Cache
  33. A PreFlight handler which sets no-cache headers on anything under `/.well-known/webfinger`. Disable or override via `wf.PreHandlers[webfinger.NoCacheMiddleware]`
  34. ### Content Type as application/jrd+json
  35. A PreFlight handler which sets the Content-Type to `application/jrd+json`. Disable or override via `wf.PreHandlers[webfinger.ContentTypeMiddleware]`.
  36. ### CORS
  37. A PreFlight handler which adds the CORS headers. Disable or override via `wf.PreHandlers[webfinger.CorsMiddleware].`