mqttwildcard

package module
v0.0.0-...-7c603f3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2021 License: MIT Imports: 1 Imported by: 0

README

mqtt-wildcard

License

Match a MQTT Topic against Wildcards

Install and Usage

go get github.com/panicneo/mqtt-wildcard

API

type MatchResult struct {
    Result []string
}

func Match(topic, wildcard string) *MatchResult{}

Returns nil if not matched, otherwise an pointer to MatchResult containing the wildcards contents will be returned.

Examples:

mqttwildcard.Match('test/foo/bar', 'test/foo/bar'); // &MatchResult{Result: []string{}}
mqttwildcard.Match('test/foo/bar', 'test/+/bar'); // &MatchResult{Result: []string{"foo"}}
mqttwildcard.Match('test/foo/bar', 'test/#'); // &MatchResult{Result: []string{"foo/bar"}}]
mqttwildcard.Match('test/foo/bar/baz', 'test/+/#'); // &MatchResult{Result: []string{"foo", "bar/baz"}}]
mqttwildcard.Match('test/foo/bar/baz', 'test/+/+/baz'); // &MatchResult{Result: []string{"foo", "bar"}}]

mqttwildcard.Match('test', 'test/#'); //  &MatchResult{Result: []string{}]
mqttwildcard.Match('test/', 'test/#'); //  &MatchResult{Result: []string{""}]

mqttwildcard.Match('test/foo/bar', 'test/+'); // nil
mqttwildcard.Match('test/foo/bar', 'test/nope/bar'); // nil

License

MIT (c) 2017 NEO

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MatchResult

type MatchResult struct {
	Result []string
}

func Match

func Match(topic, wildcard string) *MatchResult

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL