Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
add config options for proxy/subdomain
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Jan 10, 2020
1 parent a1a2db4 commit 69d023f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 10 deletions.
47 changes: 41 additions & 6 deletions gateway.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,46 @@
package config

type GatewaySpec struct {
// PathPrefixes list the set of path prefixes that should be handled by
// this gateway.
PathPrefixes []string

// UseSubdomains indicates whether or not this gateway uses subdomains
// for IPFS resources instead of paths. That is: http://CID.ipfs.GATEWAY/...
//
// If this flag is set, any /ipns/$id and/or /ipfs/$id paths in PathPrefixes
// will be permanently redirected to http://$id.[ipns|ipfs].$gateway/.
//
// We do not support using both paths and subdomains for a single domain
// for security reasons.
UseSubdomains bool

// RootRedirect is the path to which requests to `/` on this gateway
// should be redirected.
RootRedirect string
}

// Gateway contains options for the HTTP gateway server.
type Gateway struct {
HTTPHeaders map[string][]string // HTTP headers to return with the gateway
RootRedirect string
Writable bool
PathPrefixes []string
APICommands []string
NoFetch bool

// HTTPHeaders configures the headers that should be returned by this
// gateway.
HTTPHeaders map[string][]string // HTTP headers to return with the gateway

// Writable enables PUT/POST request handling by this gateway. Usually,
// writing is done through the API, not the gateway.
Writable bool

// FIXME: Not yet implemented
APICommands []string

// NoFetch configures the gateway to _not_ fetch blocks in response to
// requests.
NoFetch bool

// GatewaySpec configures the default behavior for this gateway.
GatewaySpec

// PublicGateways configures behavior of known public gateways.
PublicGateways map[string]*GatewaySpec
}
10 changes: 6 additions & 4 deletions init.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
},

Gateway: Gateway{
RootRedirect: "",
Writable: false,
NoFetch: false,
PathPrefixes: []string{},
GatewaySpec: GatewaySpec{
RootRedirect: "",
PathPrefixes: []string{},
},
Writable: false,
NoFetch: false,
HTTPHeaders: map[string][]string{
"Access-Control-Allow-Origin": []string{"*"},
"Access-Control-Allow-Methods": []string{"GET"},
Expand Down

0 comments on commit 69d023f

Please sign in to comment.