String extractor

Extract values from *http.Request or http.ResponseWriter

If you want to extract a value based on a tag name you can create your own string extractor.

You just need to implement this interface:

type Strings interface {
	Extract(req *http.Request, res http.ResponseWriter, valueOfTag string) ([]string, error)
	
	Tag() string // the tag is for instance query, path or watever you want. 
	             // Then in your inputs structures you can use `watever:"something"`
}

Then before declaring your routes add your interface implementation to the list of StringsExtractors in the config.

Like that:

kcd.Config.StringsExtractors = append(kcd.Config.StringsExtractors, YourExtractor{})

Last updated