Documentation ¶
Index ¶
- Constants
- Variables
- func AliasAndRedirectMiddleware(next http.Handler, analytics bool) http.Handler
- func AssetHandler() http.Handler
- func DevAssetHandler(path, dir string) http.Handler
- func NewRouter(logger *slog.Logger, cfg *AppConfig) (http.Handler, error)
- type AppConfig
- type Formatter
- type GnoURL
- type Metadata
- type PathKind
- type StaticMetadata
- type WebClient
- type WebHandler
- type WebHandlerConfig
Constants ¶
const DefaultChainDomain = "gno.land"
Variables ¶
var ( ErrURLMalformedPath = errors.New("malformed URL path") ErrURLInvalidPathKind = errors.New("invalid path kind") )
var Aliases = map[string]string{
"/": "/r/gnoland/home",
"/about": "/r/gnoland/pages:p/about",
"/gnolang": "/r/gnoland/pages:p/gnolang",
"/ecosystem": "/r/gnoland/pages:p/ecosystem",
"/partners": "/r/gnoland/pages:p/partners",
"/testnets": "/r/gnoland/pages:p/testnets",
"/start": "/r/gnoland/pages:p/start",
"/license": "/r/gnoland/pages:p/license",
"/contribute": "/r/gnoland/pages:p/contribute",
"/events": "/r/gnoland/events",
}
Aliases are gnoweb paths that are rewritten using AliasAndRedirectMiddleware.
var Redirects = map[string]string{
"/r/demo/boards:gnolang/6": "/r/demo/boards:gnolang/3",
"/blog": "/r/gnoland/blog",
"/gor": "/contribute",
"/game-of-realms": "/contribute",
"/grants": "/partners",
"/language": "/gnolang",
"/getting-started": "/start",
}
Redirect are gnoweb paths that are redirected using AliasAndRedirectMiddleware.
Functions ¶
func AliasAndRedirectMiddleware ¶
AliasAndRedirectMiddleware redirects all incoming requests whose path matches any of the Redirects to the corresponding URL; and rewrites the URL path for incoming requests which match any of the Aliases.
func AssetHandler ¶
AssetHandler returns the handler to serve static assets. If cache is true, these will be served using the static files embedded in the binary; otherwise they will served from the filesystem.
func DevAssetHandler ¶
Types ¶
type AppConfig ¶
type AppConfig struct { // UnsafeHTML, if enabled, allows to use HTML in the markdown. UnsafeHTML bool // Analytics enables SimpleAnalytics. Analytics bool // NodeRemote is the remote address of the gno.land node. NodeRemote string // RemoteHelp is the remote of the gno.land node, as used in the help page. RemoteHelp string // ChainID is the chain id, used for constructing the help page. ChainID string // AssetsPath is the base path to the gnoweb assets. AssetsPath string // AssetDir, if set, will be used for assets instead of the embedded public directory AssetsDir string // FaucetURL, if specified, will be the URL to which `/faucet` redirects. FaucetURL string }
AppConfig contains configuration for the gnoweb.
func NewDefaultAppConfig ¶
func NewDefaultAppConfig() *AppConfig
NewDefaultAppConfig returns a new default AppConfig. The default sets 127.0.0.1:26657 as the remote node, "dev" as the chain ID and sets up Assets to be served on /public/.
type GnoURL ¶
type GnoURL struct { Domain string // gno.land Path string // /r/demo/users Args string // jae WebQuery url.Values // help&a=b Query url.Values // c=d }
GnoURL decomposes the parts of an URL to query a realm.
func (GnoURL) EncodeArgs ¶
func (GnoURL) EncodePath ¶
func (GnoURL) EncodeWebPath ¶
type StaticMetadata ¶
type WebClient ¶
type WebClient struct {
// contains filtered or unexported fields
}
func NewWebClient ¶
func (*WebClient) Functions ¶
func (s *WebClient) Functions(pkgPath string) ([]vm.FunctionSignature, error)
func (*WebClient) SourceFile ¶
type WebHandler ¶
type WebHandler struct {
// contains filtered or unexported fields
}
func NewWebHandler ¶
func NewWebHandler(logger *slog.Logger, cfg WebHandlerConfig) *WebHandler
func (*WebHandler) Get ¶
func (h *WebHandler) Get(w http.ResponseWriter, r *http.Request)
func (*WebHandler) ServeHTTP ¶
func (h *WebHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type WebHandlerConfig ¶
type WebHandlerConfig struct { Meta StaticMetadata RenderClient *WebClient Formatter Formatter }