FirstGoApiMux

command module
v0.0.0-...-2cceb0b Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: MIT Imports: 5 Imported by: 0

README

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

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL