Example #1
0
func newUrlArgs(req *http.Request) (*urlArgs, errors.Error) {
	for arg, _ := range req.Form {
		if !isValidParameter(arg) {
			return nil, errors.NewServiceErrorUnrecognizedParameter(arg)
		}
	}
	return &urlArgs{req: req}, nil
}
Example #2
0
// create a jsonArgs structure from the given http request.
func newJsonArgs(req *http.Request) (*jsonArgs, errors.Error) {
	var p jsonArgs
	decoder := json.NewDecoder(req.Body)
	err := decoder.Decode(&p.args)
	if err != nil {
		return nil, errors.NewServiceErrorBadValue(err, "JSON request body")
	}
	for arg, _ := range p.args {
		if !isValidParameter(arg) {
			return nil, errors.NewServiceErrorUnrecognizedParameter(arg)
		}
	}
	p.req = req
	return &p, nil
}