petaki / inertia-go Goto Github PK
View Code? Open in Web Editor NEW⏩ Inertia.js server-side adapter for Go.
License: MIT License
⏩ Inertia.js server-side adapter for Go.
License: MIT License
Does using this allow for SSR of javascript front-end applications with go backend?
I've installed petaki/inertia using go get github.com/petaki/inertia-go and tried to follow the documentation,
but I'm not sure how to proceed with the Fiber integration.
Can you please help me out a bit
Apologies in advance if this is not related to the inertia-go module, which is great.
This module does not set the content-type to "text/html". I believe it relies on Go's behaviour of reading the first number of bytes and determining the content type based on that.
Locally this works fine for me and I get content-type "text/html; charset=utf8". But when I run this in an AWS Lambda function, the content type is "text/plain; charset=utf8". The browser then does not render the html.
As a workround, I've wrapped the Render
method.
func (s *Server) renderInertia(w http.ResponseWriter, r *http.Request, component string, props map[string]interface{}) error {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
return s.inertiaManager.Render(w, r, component, props)
}
This works because the content-type is overwritten for JSON responses, but this solution feels pretty bad.
Do you have any insight into why "text/plain; charset=utf8" is being set as the content-type?
Would it make sense to explicitly set the content-type in this module if no x-inertia
header exists?
Thanks for your time!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.