hussains-hedgetrimmer

command
v0.0.0-...-baafa83 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

README

The Hedge Trimmer

Source Code

package main

import (
	"context"
	"log"
	"os"
	"strings"

	"github.com/googlecloudplatform/ezcx"
)

var (
	PORT = os.Getenv("PORT")
)

func main() {
	ctx := context.Background()
	lg := log.Default()
	server := ezcx.NewServer(ctx, ":"+PORT, lg)
	server.HandleCx("/trimmer", cxHedgeTrimmer)
	server.ListenAndServe(ctx)
}

func cxHedgeTrimmer(res *ezcx.WebhookResponse, req *ezcx.WebhookRequest) error {

	trimmer := strings.NewReplacer(".", "", ",", "", " ", "")

	params := req.GetSessionParameters()

	for key, val := range params {
		strVal, ok := val.(string)
		if !ok {
			continue
		}
		params[key] = trimmer.Replace(strVal)
	}

	res.AddSessionParameters(params)
	return nil
}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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