33 lines
746 B
Go
33 lines
746 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func main() {
|
|
fmt.Println("Welcome to lst backend where all the fun happens.")
|
|
r := gin.Default()
|
|
|
|
// Serve Docusaurus static files
|
|
r.StaticFS("/lst/docs", http.Dir("docs"))
|
|
|
|
|
|
r.GET("/api/ping", func(c *gin.Context) {
|
|
c.JSON(200, gin.H{"message": "pong"})
|
|
})
|
|
|
|
r.Any("/api", errorApiLoc)
|
|
r.Any("/", errorLoc)
|
|
r.Run(":8080")
|
|
}
|
|
|
|
func errorLoc(c *gin.Context) {
|
|
c.JSON(http.StatusBadRequest, gin.H{"message": "welcome to lst system you might have just encountered an incorrect area of the app"})
|
|
}
|
|
func errorApiLoc(c *gin.Context) {
|
|
c.JSON(http.StatusBadRequest, gin.H{"message": "looks like you have encountered an api route that dose not exist"})
|
|
}
|