-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: local chain registry endpoint (#1204)
* feat: read chain registry file if found * chain_registry_assets optional endpoint
- Loading branch information
1 parent
a2d674e
commit 2a355c8
Showing
3 changed files
with
58 additions
and
3 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,31 @@ | ||
package handlers | ||
|
||
import ( | ||
"net/http" | ||
"os" | ||
) | ||
|
||
// If the chain_registry.json file is found within the current running directory, show it as an enpoint. | ||
// Used in: spawn | ||
|
||
type chainRegistry struct { | ||
DataJSON []byte `json:"data_json"` | ||
} | ||
|
||
// NewChainRegistry creates a new chainRegistry with the JSON from the file at location. | ||
func NewChainRegistry(loc string) *chainRegistry { | ||
dataJSON, err := os.ReadFile(loc) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
return &chainRegistry{ | ||
DataJSON: dataJSON, | ||
} | ||
} | ||
|
||
func (cr chainRegistry) GetChainRegistry(w http.ResponseWriter, r *http.Request) { | ||
w.Header().Set("Content-Type", "application/json") | ||
w.WriteHeader(http.StatusOK) | ||
w.Write(cr.DataJSON) | ||
} |
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