Skip to content

Instantly share code, notes, and snippets.

@fedir
Last active July 8, 2020 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fedir/b1c0790a48c2a80d016026d9d5c602ef to your computer and use it in GitHub Desktop.
Save fedir/b1c0790a48c2a80d016026d9d5c602ef to your computer and use it in GitHub Desktop.
Simple API server for SupInfo devops specialization
FROM golang:latest
RUN mkdir /app
ADD . /app/
WORKDIR /app
RUN go build -o main .
CMD ["/app/main"]
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello %s!", r.URL.Path[1:])
fmt.Println("RESTfulServ. on:5000, Controller:",r.URL.Path[1:])
})
http.HandleFunc("/hi", func(w http.ResponseWriter, r *http.Request){
fmt.Fprintf(w, "Hi")
})
log.Fatal(http.ListenAndServe(":5000", nil))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment