Giter VIP home page Giter VIP logo

Comments (4)

rs avatar rs commented on May 14, 2024

Can you show the code and the request your are trying?

from rest-layer.

omani avatar omani commented on May 14, 2024
var Users = schema.Schema{
	Description: "User Profile",
	Fields: schema.Fields{
		// default fields (a must-have on all domains)
		// "id":      schema.IDField,
		"created": schema.CreatedField,
		"updated": schema.UpdatedField,

		// fields
		"id": {
			Validator: &schema.String{
				MinLen: 2,
				MaxLen: 50,
			},
		},
		"name": {
			Required:   true,
			Filterable: true,
			Validator: &schema.String{
				MaxLen: 150,
			},
		},
		"email": {
			Required:   true,
			Filterable: true,
			Validator: &schema.String{
				Regexp: "^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:.[a-zA-Z0-9-]+)*$",
			},
		},
		"company": {
			Required:   true,
			Filterable: true,
			Validator: &schema.String{
				MaxLen: 150,
			},
		},
		"image": {
			Required:   true,
			Filterable: true,
			Validator:  &schema.String{},
		},
		"password": schema.PasswordField,
		"reset_password": {
			Params: schema.Params{
				"old_password": {
					Description: "Old password",
					Validator:   &schema.String{},
				},
				"new_password": {
					Description: "New password",
					Validator:   &schema.String{},
				},
			},
			Handler: func(ctx context.Context, value interface{}, params map[string]interface{}) (interface{}, error) {
				// your transformation logic here
				logrus.Info("hmm...no output here?")
				logrus.Info(value)
				logrus.Error(params)
				return value, nil
			},
		},
	},
}

my request:

http -b 'http://localhost:8080/users?access_token=eyJhbGciOiJIU.....' fields=='password_reset:reset_password(old_password:"oldpw",new_password:"newpw")' -v

response:

GET /users?access_token=eyJhbGciO...&fields=password_reset%3Areset_password%28old_password%3A%22oldpw%22%2Cnew_password%3A%22newpw%22%29 HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate, compress
Host: localhost:8080
User-Agent: HTTPie/0.8.0



HTTP/1.1 200 OK
Content-Length: 64
Content-Type: application/json
Date: Sat, 24 Dec 2016 19:13:11 GMT
Request-Id: b1fchhthobshd71jqu0g
Vary: Origin
X-Total: 1

{
    "list": [
        {
            "_etag": "ef1h"
        }
    ], 
    "meta": {
        "page": 0, 
        "skip": 0, 
        "total": 1
    }
}

and I see no print/log output in console where API is running.

from rest-layer.

rs avatar rs commented on May 14, 2024

This is not to be used this way. Fields parameter is a way to transform the fields output. In this example, no item is returned so there is no field to transform.

from rest-layer.

omani avatar omani commented on May 14, 2024

ok I see. thanks for clarification.

from rest-layer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.