REST

A 7-post collection

How To Run Go RESTful Service In Docker On Mac OS X

Docker is the most popular container technology nowadays and many developers run it locally on their computers and laptops. Docker can run natively on Ubuntu and some other Linux distributions, but not on Mac OS X yet. In this post we will learn how to run a simple Go RESTful service in Docker on Mac. In our example we will piggy back on a simple RESTful service developed in an earlier posts How To Create A Simple RESTful Service In Go.

Docker installation on Mac OS X

If you do not have Docker (and Docker Machine) installed, please follow official

Read more »

How To Create A Simple RESTful Service In Go

One of sweet spots of Golang is building RESTful services. Standard library package net/http provides all we need to build a simple one, and in this post we will see how easy it is.

For production code, I would highly recommend to have a look at gorilla/mux, which is widely adopted in the field. And if you need to build a RESTful service with context and middleware support, have a look at RESTful web service in Go using Goji.

A Hello World RESTful service

package main

import (  
        "fmt"
        "net/http"
)

func main() {  
        http.HandleFunc("/hello", hello)
        http.ListenAndServe(
Read more »