| 12345678910111213141516171819202122232425262728293031323334 |
- package web
- import (
- "net/http"
- "github.com/gin-gonic/gin"
- )
- // Server is the exposed struct that contains necessary configuration and setup
- // to run the web server.
- type Server struct {
- router *gin.Engine
- }
- // NewServer returns a configured instance of the web server.
- func NewServer() *Server {
- router := gin.Default()
- s := &Server{router: router}
- router.GET("/ping", ping)
- router.POST("/parse", s.parse)
- return s
- }
- // ping is a dummy function to check if the server is running and responding.
- func ping(c *gin.Context) {
- c.JSON(http.StatusOK, gin.H{"message": "pong"})
- }
- // Run runs the server!
- func (s *Server) Run() {
- s.router.Run()
- }
|