Web Server
Building Web Server with Go - Part 9
· β˜• 8 min read
This is part 9 of 15 part series on building web server with go. Checkout https://www.gophersumit.com/series/web-server/ for more. database Connecting to SQL database one of the common task for web applications. Let's see how we can work with SQL databases in Go. database/sql Go standard library comes with database\sql package. This provides Generic interface around SQL database. For using any sql database with Go (see list here : https://github.com/golang/go/wiki/SQLDrivers), there are 2 packages required, Generic database/sql and database driver for SQL database we want to use.

Building Web Server with Go - Part 8
· β˜• 5 min read
This is part 8 of 15 part series on building web server with go. Checkout https://www.gophersumit.com/series/web-server/ for more. working with JSON data Sending and accepting JSON data is very common while building REST Services. Let's see how we can build web server in Go to work with JSON data. encoding/json To work wit JSON data we will be using encoding/json standard library package. We have two main constructs while working with JSON data.

Building Web Server with Go - Part 7
· β˜• 5 min read
This is part 7 of 15 part series on building web server with go. Checkout https://www.gophersumit.com/series/web-server/ for more. Working with static files Most of the web applications need to server static file one way or another. These files may include plain html, css, js files or assets like images, audios etc. Go providers built in handler to work with static files. fileserver net/http has FileServer handler defined which returns a static file server.

Building Web Server with Go - Part 6
· β˜• 4 min read
This is part 6 of 15 part series on building web server with go. Checkout https://www.gophersumit.com/series/web-server/ for more. middleware Middleware is used to provide a processing pipeline for web servers. Middleware is way of providing shared processing functionality for our web handlers. Whenever there is incoming request to our web server, we may want to log it, check if user is authorized etc. While sending response back to client, we may want to perform compressions, set some custom headers etc.

Building Web Server with Go - Part 5
· β˜• 8 min read
This is part 5 of 15 part series on building web server with go. Checkout https://www.gophersumit.com/series/web-server/ for more. html templates template is what it sounds like. It is a predefined html with placeholders to render data. This template is not directly returned to user, it is first parsed by a component called template engine. The work of template engine involves parsing the html and replacing the placeholders with actual data that is provided to template engine.

Building Web Server with Go - Part 4
· β˜• 8 min read
This is part 4 of 15 part series on building web server with go. Checkout https://www.gophersumit.com/series/web-server/ for more. forms HTML forms are used to collect data from user. In this part, we will build simple html form that can be used to submit data and save on server. For user to be able to submit data, we will have to user html <form> tag with post action. Form tag defines other inputs which are used to collect data fields like text, dates, choices etc.

Building Web Server with Go - Part 3
· β˜• 6 min read
This is part 3 of 15 part series on building web server with go. Checkout https://www.gophersumit.com/series/web-server/ for more. working with cookies Since http is stateless, various alternatives are used to maintain data between various requests and one such construct is cookie. An HTTP cookie (web cookie, browser cookie) is a small piece of data that a server sends to the user's web browser. The browser may store it and send it back with the next request to the same server.

Building Web Server with Go - Part 2
· β˜• 8 min read
This is part 2 of 15 part series on building web server with go. Checkout https://www.gophersumit.com/series/web-server/ for more. http request Http request is represented by request struct in Go. This is responsible for holding all the information related to incoming http request while building server. Request struct is defined in Go Std library When an http request is received, we can extract request related information. We can extract multiple details from incoming request like

Building Web Server with Go - Part 1
· β˜• 5 min read
This is part 1 of 15 part series on building web server with go. Checkout https://www.gophersumit.com/series/web-server/ for more. net/http package net/http package comes as part of standard library of Go. This provides HTTP client and server implementations. For building web servers with Go, there is no external library required. package documentation https://golang.org/pkg/net/http/ simple web server Writing a simple web server is trivial in Go. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 package main import "net/http" func hello(w http.