Skip to content

Commit

Permalink
Add utility function for setting domain
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarema authored and Tomasz Pietrek committed Jun 17, 2021
1 parent e4b051a commit 72f7fec
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions js.go
Expand Up @@ -35,6 +35,9 @@ const (
// defaultAPIPrefix is the default prefix for the JetStream API.
defaultAPIPrefix = "$JS.API."

// jsDomainT is used to create JetStream API prefix by specifying only Domain
jsDomainT = "$JS.%s.API."

// apiAccountInfo is for obtaining general information about JetStream.
apiAccountInfo = "INFO"

Expand Down Expand Up @@ -200,6 +203,11 @@ func (opt jsOptFn) configureJSContext(opts *jsOpts) error {
return opt(opts)
}

// Domain changes the domain part of JetSteam API prefix.
func Domain(domain string) JSOpt {
return APIPrefix(fmt.Sprintf(jsDomainT, domain))
}

// APIPrefix changes the default prefix used for the JetStream API.
func APIPrefix(pre string) JSOpt {
return jsOptFn(func(js *jsOpts) error {
Expand Down

0 comments on commit 72f7fec

Please sign in to comment.