Building Micro-services with GO | Part1

  • Developing Microservices in GO.
  • Creating Http Web Server in GO.
  • Read the request body in GO.
  • Write the response back in GO.
  • Handling Error in Go.
  • Accessing the handler from different package in Go.
  • It registers the handler function for the given pattern in the DefaultServeMux.
  • It creates an HttpHandler from it and adds it to the DefaultServeMux.
  • It is responsible for redirecting the paths. It contains the logic to be able to determine, which particular handler is to be called based upon the path.
  • Basically, it determines, which function would get executed whenever a request lands, depending upon where it has been mapped.
  • “http” package does have a DefaultServeMux. If we don’t set anything else up, this is the one, which is used by HandleFunc() function.
  • It allows you to have multiple handlers.
  • First parameter indicates the Port, where this server shall be hosted.
  • Second parameter indicates the Handler as simple as that. If we don’t specify anything
  • In the left-terminal, we have started our server.
  • In the right-terminal, we have verified by hitting to the hosted API.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
aditya goel

aditya goel

Software Engineer for Big Data distributed systems