Reorganized API + added db migrations
Read the README file for more informations
This commit is contained in:
26
backend/api/shortcodes/shortcodes.go
Normal file
26
backend/api/shortcodes/shortcodes.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package shortcodes
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"fr.latosa-escrima/api/core"
|
||||
)
|
||||
|
||||
func HandleShortcodes(w http.ResponseWriter, r *http.Request) {
|
||||
var shortcodes []core.Shortcode
|
||||
err := core.DB.NewSelect().Model(&shortcodes).Scan(context.Background())
|
||||
if err != nil {
|
||||
core.JSONError{
|
||||
Status: core.Error,
|
||||
Message: err.Error(),
|
||||
}.Respond(w, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
core.JSONSuccess{
|
||||
Status: core.Success,
|
||||
Message: "Shortcodes retrieved.",
|
||||
Data: shortcodes,
|
||||
}.Respond(w, http.StatusOK)
|
||||
}
|
||||
Reference in New Issue
Block a user