Skip to content

Commit

Permalink
docs: add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Jan 25, 2023
1 parent 5e17bce commit 25f77d2
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions core/corehttp/gateway/README.md
Original file line number Diff line number Diff line change
@@ -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)
```

0 comments on commit 25f77d2

Please sign in to comment.