ponzu-cms / ponzu

Headless CMS with automatic JSON API. Featuring auto-HTTPS from Let's Encrypt, HTTP/2 Server Push, and flexible server framework written in Go.
https://docs.ponzu-cms.org
BSD 3-Clause "New" or "Revised" License
5.68k stars 386 forks source link

Integrate ponzu with my existing Gin-Gonic framework #230

Closed calvinsug closed 5 years ago

calvinsug commented 6 years ago

Hi, i would like to install Ponzu in my Golang with Gin-gonic framework for my CMS, is it possible ? Because when i see the structure of Ponzu, it seems like a different framework

nilslice commented 6 years ago

@calvinsug - yes it is possible. Are you trying to get data from Ponzu into your Gin app, or extend a Ponzu instance with Gin routes? Either way will work - mount the Gin handler on some route to the http.ServeMux (ponzu uses no framework, just the std lib). Or, use the go-client (https://github.com/ponzu-cms/go-client) to interact with a Ponzu CMS from your Gin app.

If you want to run both the Gin app and Ponzu on the same process, you need to set it up like this: https://github.com/nilslice/appback https://github.com/nilslice/appfront

In the above, appfront defines the router and routes (e.g. your Gin app), and appback is the Ponzu CMS. You can see how another router is mounted on top of Ponzu here: https://github.com/nilslice/appback/blob/master/content/about.go#L54

Just be aware, if you go the route of using Ponzu's go-client, the example code in appfront wont work now that the go-client uses it's own version of Values. e.g. here: https://github.com/nilslice/appfront/blob/master/app.go#L112 is going to be broken.

calvinsug commented 6 years ago

wow, thanks for your response, and the last thing i need to consider is for my Database, i'm using MongoDB from mgo package (https://gopkg.in/mgo.v2), and after i read from your documentation, i realized that Ponzu using BoltDB right ? Is it possible to use MongoDB for my database in my Ponzu CMS ?

nilslice commented 6 years ago

Sure thing, hope it was helpful.

Unfortunately, without forking the project and implementing the mongodb operations in place of the existing boltdb ones, there is no built-in way to swap out the database. It's not impossible though and I'd love to see a version of ponzu with another DB implementation! Though it isn't something I am personally working on at this time.

olliephillips commented 5 years ago

Closing this issue. It appears to be answered/resolved. Please reopen if not the case.