gernest / utron

A lightweight MVC framework for Go(Golang)
MIT License
2.22k stars 149 forks source link

Use Utron like Api-JSON #91

Closed santi0037 closed 6 years ago

santi0037 commented 6 years ago

Hello friends, happy new year! I'm totally new with golang and I'm trying to turn utron in an Api-JSON. Reading the code i found that "data will only be used when Template is not specified and there is no View set. You can use this for creating APIs (which does not depend on views like JSON APIs)"

My cuestion is, what are the next steps should i follow?

nicola-spb commented 6 years ago

Hi guy, happy new year!

1) You should create controller. 2) Add method for your url 3) Use this method for return JSON c.RenderJSON(<object or map>, http.StatusOK)

Maybe I don`t understand your question. Can you give me example?

santi0037 commented 6 years ago

Thanks you! My mistake was to put a ctx before RenderJSON t.Ctx.RenderJSON(peoples, http.StatusOK) and now is working perfectly!!!

nicola-spb commented 6 years ago

You are welcome. Good!