Skip to content

A tiny RestFul API is written in Go with Mux HTTP router.

License

Notifications You must be signed in to change notification settings

BaseMax/FirstGoApiMux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

First Go Api Mux

A tiny RestFul API is written in Go with Mux HTTP router.

Router

router := mux.NewRouter().StrictSlash(true)
router.HandleFunc("/", homePage).Methods("GET")
router.HandleFunc("/investories", getInvestories).Methods("GET")
router.HandleFunc("/investory/{uid}", getInvestory).Methods("GET")
router.HandleFunc("/investory", createInvestory).Methods("POST")
router.HandleFunc("/investory/{uid}", deleteInvestory).Methods("DELETE")
router.HandleFunc("/investory/{uid}", updateInvestory).Methods("PUT")
log.Fatal(http.ListenAndServe(":8000", router))

WHAT'S IS MUX?

A powerful HTTP router and URL matcher for building Go web servers with gorilla. (https://github.com/gorilla/mux)

Getting start

go get -u github.com/gorilla/mux
go mod init
go mod init github.com/basemax/FirstGoApiMux
go mod tidy
go run main.go
go build

References

Copyright 2021, Max Base

About

A tiny RestFul API is written in Go with Mux HTTP router.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages