I used net/http package to build up the http server with golang. Also,I make the simple Html page for front end . But I don't know how
to do for inserting input data(http request post method) into
postgresql database ? Any one could provide the sample code ?

This may not be the best Go code ever written but it does what you ask for: read a HTTP POST request body and write it into a PostgreSQL database:

Handle the HTTP POST request JSON body:

https://github.com/lutzhorn/shortenyoururl-go/blob/ece65aa0bc7b4bbd12d4b3daf039e762b16728f9/handler.go#L135

Insert the scanned body into the database:

https://github.com/lutzhorn/shortenyoururl-go/blob/ece65aa0bc7b4bbd12d4b3daf039e762b16728f9/handler.go#L179

https://github.com/lutzhorn/shortenyoururl-go/blob/ece65aa0bc7b4bbd12d4b3daf039e762b16728f9/db.go#L95

Regards

Lutz

--
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.

Reply via email to