-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbase.go
28 lines (22 loc) · 939 Bytes
/
base.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
package server
import (
"net/http"
"github.com/julienschmidt/httprouter"
apirouter "github.com/mrz1836/go-api-router"
)
// index basic request to /
func index(w http.ResponseWriter, req *http.Request, _ httprouter.Params) {
apirouter.ReturnResponse(w, req, http.StatusOK, map[string]interface{}{"message": "Welcome to the Paymail Server ✌(◕‿-)✌"})
}
// health is a basic request to return a health response
func health(w http.ResponseWriter, _ *http.Request, _ httprouter.Params) {
w.WriteHeader(http.StatusOK)
}
// notFound handles all 404 requests
func notFound(w http.ResponseWriter, req *http.Request) {
ErrorResponse(w, req, ErrorRequestNotFound, "request not found", http.StatusNotFound)
}
// methodNotAllowed handles all 405 requests
func methodNotAllowed(w http.ResponseWriter, req *http.Request) {
ErrorResponse(w, req, ErrorMethodNotFound, "method "+req.Method+" not allowed", http.StatusMethodNotAllowed)
}