[go-nuts] Re: Using React with Golang? and does it make sense?

2017-02-07 Thread Сергей Камардин
My opinion is that server side rendering is just temporary thing for search 
engine optimizations. 

But, if you really need it, you could use Node.js as client to your go api. 
Then, nginx as a front proxy, could serve static assets with and without 
backend data from go api. For example, if Node.js is running, then proxy 
index.html request there. If not just reply with empty html that will be filled 
by requests from browser to your go api.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Using React with Golang? and does it make sense?

2017-02-06 Thread Kevin Powick

On Monday, 6 February 2017 23:37:15 UTC-5, so.q...@gmail.com wrote:
>
>
> You said that Node is not required. But I thought react components are 
> actually JavaScript objects.
>

They are.  They execute on the client side, in the web browser.

 

> Would my Golang API server be responding back to requests with those 
> JavaScript objects for the React library to render on the client's browser?
>


Your Go API service would be responding with data (presumably from a 
database), formatted as JSON.  The data would have been requested by the 
React objects executing in the client browser.

*Example*

Suppose you have a Go service that returns details about a customer for a 
given a customer ID.  The endpoint might be an HTTP GET request that looks 
like the following

http://myService/customer/123456

The details are returned in JSON format

{"Id":123456,"Name":"Bob Smith","Age":25}


On the client side, you would have used JavaScript/React to make the API 
Call (HTTP GET) and populate your React object with the returned data, 
which would then be rendered in your browser UI (page).

The advantage of your Go service simply returning JSON data is that it can 
be consumed by any client software capable of an HTTP request.  This make 
it available to any number of languages with HTTP Client libraries 
available.  These days, that's pretty much any language you would care to 
work with.  

--
Kevin Powick

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Using React with Golang? and does it make sense?

2017-02-06 Thread mark
A little over a year ago, I experimented with server-side React rendering 
in Go [1] via otto [2].

At least back then, otto wasn't fully ECMA5-compliant due to not supporting 
negative lookaheads in regular expressions;
I had to open a PR on React [3] to remove one negative lookahead in the 
render path.

I have no idea if otto can run the current version of React, and it's been 
so long since I've tried using otto with React that I won't be able to 
answer any questions about that setup.
Hopefully this was still useful information.

[1] https://github.com/mark-rushakoff/go-reactjs-benchmarks
[2] https://github.com/robertkrimen/otto
[3] https://github.com/facebook/react/pull/5614

On Monday, February 6, 2017 at 9:09:10 AM UTC-8, so.q...@gmail.com wrote:
>
> Correct me if I'm wrong, but in serving web apps and sites.
>
> Golang simply fills in the blanks for predefined templates.
>
> React appears to be a bit more complicated requiring the creation of 
> JavaScript/JSX classes representing the view. Having that rendered on the 
> server-side and the difference applied on the client.
>
> To combine the two, do I need to run Node.js on the server to process the 
> React/JSX classes before piping the results to Golang for responding to the 
> client? So Golang would be the conduit/middle-man filling in for Express 
> here.
>
> Does this even make sense? If I'm already running Node.js, does the use of 
> Golang feel superfluous?
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Using React with Golang? and does it make sense?

2017-02-06 Thread so . query
Thanks for the comment.

You said that Node is not required. But I thought react components are 
actually JavaScript objects. Would my Golang API server be responding back 
to requests with those JavaScript objects for the React library to render 
on the client's browser?




On Monday, February 6, 2017 at 4:29:43 PM UTC-8, Kevin Powick wrote:
>
> React is one of many client side (browser) JavaScript frameworks for 
> building user interfaces.
>
> JSX is not required when using React, but is recommended as it gives you 
> the full power of JavaScript to describe your rendered HTML.
>
> Node is not required.  If you're using Go, use it to build a server-side 
> JSON API and, optionally, act as your web server.
>
> Our last project was a Go based API service with the HTML/JS/CCS served-up 
> by Caddy (a web server written in Go).  On the client side we used VueJS, 
> one of the bazillion alternatives to React.
>
> It's all works quite well, and I would recommend a similar approach for 
> those looking to use a Go based solution.  i.e. Go JSON API services with 
> your web server and JS framework of choice.
>
> --
> Kevin Powick
>
> On Monday, 6 February 2017 12:09:10 UTC-5, so.q...@gmail.com wrote:
>>
>> Correct me if I'm wrong, but in serving web apps and sites.
>>
>> Golang simply fills in the blanks for predefined templates.
>>
>> React appears to be a bit more complicated requiring the creation of 
>> JavaScript/JSX classes representing the view. Having that rendered on the 
>> server-side and the difference applied on the client.
>>
>> To combine the two, do I need to run Node.js on the server to process the 
>> React/JSX classes before piping the results to Golang for responding to the 
>> client? So Golang would be the conduit/middle-man filling in for Express 
>> here.
>>
>> Does this even make sense? If I'm already running Node.js, does the use 
>> of Golang feel superfluous?
>>
>>
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Using React with Golang? and does it make sense?

2017-02-06 Thread ivan
You don't have to use server-side rendering. You can have the React client 
make ajax requests to your Go backend.

On Monday, February 6, 2017 at 12:09:10 PM UTC-5, so.q...@gmail.com wrote:
>
> Correct me if I'm wrong, but in serving web apps and sites.
>
> Golang simply fills in the blanks for predefined templates.
>
> React appears to be a bit more complicated requiring the creation of 
> JavaScript/JSX classes representing the view. Having that rendered on the 
> server-side and the difference applied on the client.
>
> To combine the two, do I need to run Node.js on the server to process the 
> React/JSX classes before piping the results to Golang for responding to the 
> client? So Golang would be the conduit/middle-man filling in for Express 
> here.
>
> Does this even make sense? If I'm already running Node.js, does the use of 
> Golang feel superfluous?
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.