Giter Site home page Giter Site logo

Comments (4)

matryer avatar matryer commented on September 28, 2024

If they’re static pages - you can use the MapStatic stuff alongside the other controllers. Usually there’s no folder prefix for html pages, they’d just be “payment/x.html” or whatever.

BUT where will you be hosting this in production!? nginx might be a nicer way to route the static stuff through?

Mat

On Nov 10, 2013, at 12:28 PM, Oleksandr Lobunets [email protected] wrote:

Posting it here as I don't see much activity in the chat or stackoverflow around goweb.
The pain of integration with certain payment providers requires a couple of HTML pages to be rendered by the backend, where the user can perform some minimal interaction.

What would be the good practice here when the whole backend is build with goweb?
Options:

Implement with goweb and expose via /html or similar (while the API is exposed via /api)
Implement with pure go net/http package as part of the SAME server and expose via something like /html (while the API is exposed via /api)
Implement with whatever you feel comfortable but run as a separate server.
Other options?

Reply to this email directly or view it on GitHub.

from goweb.

oleksandr avatar oleksandr commented on September 28, 2024

Thanks. I'm aware about MapStatic, although we don't use it - rather serving the client app directly form the front-end nginx. In the case I described above the pages are "dynamic", rendered on the server-side. That is what makes this a bit more complex. I guess moving towards client-side rendering and just adding additional API here would be the cleanest way to k.i.s.s.

from goweb.

matryer avatar matryer commented on September 28, 2024

Yes - that's what we prefer. But if you have to do rendering on the server, just use goweb.Map to map to a different set of functions that do the work. Go has quite a few templating frameworks too (I like mustache).

from goweb.

oleksandr avatar oleksandr commented on September 28, 2024

That was the final way we went. So we just mapped a handler with goweb.Map and used

ctx.HttpResponseWriter().Header().Set("Content-Type", "text/html")
return goweb.Respond.With(ctx, http.StatusOK, body.Bytes())

to render the HTML.

BTW, if that can be anyone helpful - we didn't want to lose the beauty of 1-file deployment bringing in just a couple of template files. We used this great tool to compile template into the final binary: https://github.com/jteeuwen/go-bindata

The dev pipeline became not that complex: edit html, run go-bindata something like:

bin/go-bindata -prefix="template" -pkg="templates" -uncompressed=false -out=./src/mypackage/payment/templates/index.go -func="IndexTemplate" src/mypackage/payment/templates/index.html

and then simple import index.go and use IndexTemplate variable to Parse/Execute (in case html/template is used).

from goweb.

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.