-
Notifications
You must be signed in to change notification settings - Fork 71
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
8 changed files
with
118 additions
and
28 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
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,29 @@ | ||
package gql | ||
|
||
import ( | ||
"encoding/json" | ||
"net/http" | ||
) | ||
|
||
type webConfigIpni struct { | ||
IndexerHost string | ||
} | ||
|
||
type webConfig struct { | ||
Ipni webConfigIpni | ||
} | ||
|
||
type webConfigServer struct { | ||
cfg webConfig | ||
} | ||
|
||
func (s *webConfigServer) ServeHTTP(writer http.ResponseWriter, request *http.Request) { | ||
bz, err := json.Marshal(&s.cfg) | ||
if err != nil { | ||
writer.Write([]byte("error serving web config: " + err.Error())) | ||
writer.WriteHeader(500) | ||
return | ||
} | ||
|
||
writer.Write(bz) | ||
} |
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
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
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
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
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,22 @@ | ||
var config | ||
|
||
export async function initConfig() { | ||
var serverEndpoint = window.location.host | ||
var serverHttpEndpoint = window.location.origin | ||
|
||
if (process.env.NODE_ENV === 'development') { | ||
serverEndpoint = 'localhost:8080' | ||
serverHttpEndpoint = 'http://' + serverEndpoint | ||
} | ||
|
||
const res = await fetch(serverHttpEndpoint+'/config.json') | ||
config = await res.json() | ||
} | ||
|
||
export function setConfig(cfg) { | ||
config = cfg | ||
} | ||
|
||
export function getConfig() { | ||
return config | ||
} |
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