-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
45 lines (39 loc) · 1.13 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"fmt"
"log"
"net/http"
"os"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
)
func main() {
r := mux.NewRouter()
/**
* @api {GET} / get help about this block
* @apiName Intro
*/
r.HandleFunc("/", Intro)
/**
* @api {GET} /get echoes back what you send it in the query params
* @apiName GetEcho
* @apiParam (Url) {String} key1 value of key1
* @apiParam (Url) {String} [key2] value of key2
* @apiSuccess {Object} data the query params encoded as a JSON object
* @apiError (400) error.message the error message
*/
r.HandleFunc("/get", GetEcho).Methods("GET")
/**
* @api {POST} /post echoes back what you send it in the request body
* @apiName PostEcho
* @apiParam (Body) {String} key1 value of key1
* @apiParam (Body) {String} [key2] value of key2
* @apiSuccess {Object} data the request body encoded as a JSON object
* @apiError (400) error.message the error message
*/
r.HandleFunc("/post", PostEcho).Methods("POST")
loggingRouter := handlers.LoggingHandler(os.Stdout, r)
http.Handle("/", loggingRouter)
fmt.Println("Starting server at 80")
log.Fatal(http.ListenAndServe(":80", nil))
}