From 1929ff3a91091123142eb9cfbbb017b193be78b1 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Wed, 25 Jan 2023 14:49:25 +0100 Subject: [PATCH] docs: add readme --- core/corehttp/gateway/README.md | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 core/corehttp/gateway/README.md diff --git a/core/corehttp/gateway/README.md b/core/corehttp/gateway/README.md new file mode 100644 index 00000000000..102121d92de --- /dev/null +++ b/core/corehttp/gateway/README.md @@ -0,0 +1,35 @@ +# IPFS Gateway + +> IPFS Gateway HTTP handler. + +## Documentation + +* Go Documentation: https://pkg.go.dev/github.com/ipfs/kubo/core/corehttp/gateway + +## Example + +```go +// Initialize your headers and apply the default headers. +headers := map[string][]string{} +gateway.AddAccessControlHeaders(headers) + +conf := gateway.Config{ + Writable: false, + Headers: headers, +} + +// Initialize a NodeAPI interface for both an online and offline versions. +// The offline version should not make any network request for missing content. +ipfs := ... +offlineIPFS := ... + +// Create http mux and setup gateway handler. +mux := http.NewServeMux() +gwHandler := gateway.NewHandler(conf, ipfs, offlineIPFS) +mux.Handle("/ipfs/", gwHandler) +mux.Handle("/ipns/", gwHandler) + +// Start the server on :8080 and voilá! You have an IPFS gateway running +// in http://localhost:8080. +_ = http.ListenAndServe(":8080", mux) +``` \ No newline at end of file