PathrockNetwork Gno Explorer
HomeBlocksTransactionsTokensRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/p/nt/mux/v0

Package
Open in gnoweb ↗

Overview

Kind
Pure package
Name
v0
Namespace
nt / mux
Files
10 (README)(gnomod.toml)
Exported functions
n/a — not supported for pure packages by the node (vm/qfuncs)
Module
gno.land/p/nt/mux/v0
gno
0.9

Files (10)

  • README.mdmarkdown
  • gnomod.tomltoml
  • doc.gnogno
  • handler.gnogno
  • helpers.gnogno
  • request.gnogno
  • response.gnogno
  • router.gnogno
  • request_test.gnogno
  • router_test.gnogno
  • request_test.gnogno
    1package mux23import (4	"testing"56	"gno.land/p/nt/uassert/v0"7	"gno.land/p/nt/ufmt/v0"8)910func TestRequest_GetVar(t *testing.T) {11	cases := []struct {12		handlerPath    string13		reqPath        string14		getVarKey      string15		expectedOutput string16	}{1718		{"users/{id}", "users/123", "id", "123"},19		{"users/123", "users/123", "id", ""},20		{"users/{id}", "users/123", "nonexistent", ""},21		{"users/{userId}/posts/{postId}", "users/123/posts/456", "userId", "123"},22		{"users/{userId}/posts/{postId}", "users/123/posts/456", "postId", "456"},2324		// Wildcards25		{"*", "users/123", "*", "users/123"},26		{"*", "users/123/posts/456", "*", "users/123/posts/456"},27		{"*", "users/123/posts/456/comments/789", "*", "users/123/posts/456/comments/789"},28		{"users/*", "users/john/posts", "*", "john/posts"},29		{"users/*/comments", "users/jane/comments", "*", "jane/comments"},30		{"api/*/posts/*", "api/v1/posts/123", "*", "v1/posts/123"},3132		// wildcards and parameters33		{"api/{version}/*", "api/v1/user/settings", "version", "v1"},34	}35	for _, tt := range cases {36		name := ufmt.Sprintf("%s-%s", tt.handlerPath, tt.reqPath)37		t.Run(name, func(t *testing.T) {38			req := &Request{39				HandlerPath: tt.handlerPath,40				Path:        tt.reqPath,41			}42			output := req.GetVar(tt.getVarKey)43			uassert.Equal(t, tt.expectedOutput, output,44				"handler: %q, path: %q, key: %q",45				tt.handlerPath, tt.reqPath, tt.getVarKey)46		})47	}48}49

    Functions

    not supported for pure packages by the node (vm/qfuncs)

    Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.