Skip to content

How to define a wildcard path in a way that lets me access the wildcard part as (input) variable #432

Answered by x-user
BerwoutK asked this question in Q&A
Discussion options

You must be logged in to vote

This will work if fiber

app := fiber.New()
api := humafiber.New(app, huma.DefaultConfig("API", "0.0.1"))

huma.Get(
	api,
		"/test/+",
	func(
		ctx context.Context,
		input *struct {
			Sub string `path:"+"`
		},
	) (*struct{}, error) {
		slog.LogAttrs(
			context.Background(),
			slog.LevelInfo,
			"test route",
			slog.String("sub", input.Sub),
		)
		return nil, nil
	},
)

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@BerwoutK
Comment options

@x-user
Comment options

@BerwoutK
Comment options

@x-user
Comment options

Answer selected by BerwoutK
@BerwoutK
Comment options

@x-user
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants