package module
Version: v0.0.0-...-893f695 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2019 License: Apache-2.0 Imports: 4 Imported by: 0


WebService Lab


And that's a Wrap!! Decorate your user greeter as a Web Service...

  • Ensure your web server is listening on port 4500
  • Create an HTTP service with two endpoints ie / and /greet
  • If the user hits / the service should produce a no route match error with a 400 status code
  • /greet serves out new greetings
    • The request should take query parameters for the user name and age
    • You should issue a JSON response!
  • Make sure the proper JSON headers are set
  • Write the necessary tests to shake out your endpoints!
  • Run your web service using cmd/svc/main.go
  • Now run your cli to call your web service cmd/cli/main.go
  • [BONUS] Hit a classmate greeting service if you share the same network

Expected Output

    "Age": 42,
    "Greeting": "Greetings Fernand! You are now 42 years old...",
    "Name": "Fernand"

OSX Brew Installs (Totally Optional!!)

# Install httpie
brew install httpie


# Start your web server
go run cmd/srv/main.go
# Hit the new_word url classic
curl -XGET 'http://localhost:4500/greet?name=Fernand&age=42'
# Or...
http :4500/greet name==Fernand age==42
# Run the cli
go run cmd/cli/main.go -age 10 -name fred -url localhost:4500

© 2019 Imhotep Software LLC. All materials licensed under Apache v2.0




This section is empty.


This section is empty.


func GreetingHandler

func GreetingHandler(w http.ResponseWriter, r *http.Request)

GreetingHandler greats incoming users.

func NoMatchHandler

func NoMatchHandler(w http.ResponseWriter, r *http.Request)

NoMatchHandler is used when no known endpoints.

func SetupRoutes

func SetupRoutes()

SetupRoutes for various endpoints.


type Response

type Response struct {
	Greeting, Name string
	Age            int

Response greeting message format.

Source Files


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL