-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
``` |