Comments (4)
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.
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.
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.
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)
- make controller mapping methods configurable HOT 1
- Add ability to store state in handlers
- RestfulManyUpdater has wrong mapping HOT 5
- Don't envelop data in responses by default HOT 9
- Remove unnecessary stuff from APIResponder interface
- Example for injecting database into context HOT 5
- Simplified API in the future? Goweb use too many []interface{} for args HOT 4
- The server's binary gets all the test flags HOT 5
- Gzip Compression HOT 3
- Figure out real status with always200 HOT 1
- web_context.go's FileExtention also returns query parameters HOT 1
- Dotted urls may confuse goweb parameters HOT 2
- Over-eager path matching HOT 2
- panic with index out of range when call PathPattern.GetPathMatch HOT 2
- BeforeHandler.Before() where are errors returned to? HOT 3
- Testing Controllers?
- Why aren't dotted values allowed for resource ids? HOT 2
- putting controllers in different files HOT 1
- SSL Support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from goweb.