#Golang-Web-Server

20 articles

08 How to Understanding File Server in Golang

08 How to Understanding File Server in Golang

Introduction to File Server

Golang has a feature called FileServer. With this we can create a Handler in Golang Web that we have used as a static file server and this FileServer does not need to be manually loaded again. So we can add it to http.Server or http.ServeMux.

07 How to Understanding Cookie in Golang

07 How to Understanding Cookie in Golang

Introduction to Cookies

Before discussing Cookies, we need to know that HTTP is stateless between client and server, which means the server does not store any data to remember every request from the client. This aims to make it easy to scale the server itself. So how do you get the server to remember a client? for example, when we have logged in to a website, the server must automatically know that the client has logged in so that subsequent requests no longer require logging in. For things like this, we can usually use Cookies.

06 How to Used Response Code in Golang

06 How to Used Response Code in Golang

Introduction to Response Codes

Something we also need to know about HTTP is the response code. This is a representation of the response code, where from this code we can see whether a request we sent from the client was successfully processed by the server or failed to be processed by the server. So there are lots of response codes that we can use when creating a website. You can immediately look in more depth at several HTTP Status Codes here https://developer.mozilla.org/en-US/docs/Web/HTTP/Status

05 How to Used Request Form Post in Golang

05 How to Used Request Form Post in Golang

Introduction to Post Forms

Similar to the previous post, when we use the GET method, the results of all the data in the form will be a param query, whereas if we use POST then all the data in the form is sent via the body of the HTTP Request, only the method is different. All form post data sent from the client will automatically be stored in the Request.PostFrom attribute. However, before we can retrieve the PostForm attribute data, we must first call the Request.ParseForm() method and then this method will be used to parse the body. Parsing this data will produce form data, if it is not there it will cause an error in the parsing.

04 How to Used Request Header in Golang

04 How to Used Request Header in Golang

Header Introduction

Apart from query parameters on HTTP, we can also use Headers. Headers are additional information that is usually sent from the client to the server or vice versa. In the Header, not only in the HTTP Request but in the HTTP Response we can also add header information. When we use a browser on our computer, usually headers will automatically be displayed by the browser such as browser information, types of content sent and received by the browser and much more.

03 How To Used Query Parameter in Golang

03 How To Used Query Parameter in Golang

Introduction to Query Parameters

Query parameters are one of the features of http that we usually use to send data from the client to the server. This parameter query is placed in the URL of the endpoint that we have created. To add query parameters, we can use ?=name=value in our website URL.

02 How to Used HTTP Test in Golang

02 How to Used HTTP Test in Golang

Introduction to HTTP Testing

HTTP Test in Golang has been provided with a special package for creating unit tests for Web features. All of this is in the net/http/httptest package https://golang.org/pkg/net/http/httptest/. By using this package, we can unit test the web handler that we have created without having to run the web application so that we can immediately focus on the handler function that we want to test.

01 Introduction Golang Web Server

01 Introduction Golang Web Server

Web Introduction

The web is a collection of information available on a computer that is connected directly via the internet. This website contains information in any form such as text, audio, video and others. The web runs on an application called a web server, which is an application used to store and convey the contents of web information.