107 lines
1.8 KiB
Go
107 lines
1.8 KiB
Go
// Package routes contains endpoint handlers for the myPrayerJournal API.
|
|
package routes
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
routing "github.com/go-ozzo/ozzo-routing"
|
|
)
|
|
|
|
// Route is a route served in the application.
|
|
type Route struct {
|
|
Name string
|
|
Method string
|
|
Pattern string
|
|
Func routing.Handler
|
|
IsPublic bool
|
|
}
|
|
|
|
// Routes is the collection of all routes served in the application.
|
|
type Routes []Route
|
|
|
|
// routes is the actual list of routes for the application.
|
|
var routes = Routes{
|
|
Route{
|
|
"Journal",
|
|
http.MethodGet,
|
|
"/api/journal/",
|
|
journal,
|
|
false,
|
|
},
|
|
Route{
|
|
"AddNewRequest",
|
|
http.MethodPost,
|
|
"/api/request/",
|
|
requestAdd,
|
|
false,
|
|
},
|
|
// Must be above GetRequestByID
|
|
Route{
|
|
"GetAnsweredRequests",
|
|
http.MethodGet,
|
|
"/api/request/answered",
|
|
requestsAnswered,
|
|
false,
|
|
},
|
|
Route{
|
|
"GetRequestByID",
|
|
http.MethodGet,
|
|
"/api/request/<id>",
|
|
requestGet,
|
|
false,
|
|
},
|
|
Route{
|
|
"GetCompleteRequestByID",
|
|
http.MethodGet,
|
|
"/api/request/<id>/complete",
|
|
requestGetComplete,
|
|
false,
|
|
},
|
|
Route{
|
|
"GetFullRequestByID",
|
|
http.MethodGet,
|
|
"/api/request/<id>/full",
|
|
requestGetFull,
|
|
false,
|
|
},
|
|
Route{
|
|
"AddNewHistoryEntry",
|
|
http.MethodPost,
|
|
"/api/request/<id>/history",
|
|
requestAddHistory,
|
|
false,
|
|
},
|
|
Route{
|
|
"AddNewNote",
|
|
http.MethodPost,
|
|
"/api/request/<id>/note",
|
|
requestAddNote,
|
|
false,
|
|
},
|
|
Route{
|
|
"GetNotesForRequest",
|
|
http.MethodGet,
|
|
"/api/request/<id>/notes",
|
|
requestGetNotes,
|
|
false,
|
|
},
|
|
Route{
|
|
"SnoozeRequest",
|
|
http.MethodPost,
|
|
"/api/request/<id>/snooze",
|
|
requestSnooze,
|
|
false,
|
|
},
|
|
// keep this route last
|
|
Route{
|
|
"StaticFiles",
|
|
http.MethodGet,
|
|
"/*",
|
|
staticFiles,
|
|
true,
|
|
},
|
|
}
|
|
|
|
// ClientPrefixes is a list of known route prefixes handled by the Vue app.
|
|
var ClientPrefixes = []string{"/answered", "/journal", "/user"}
|