Sushi/server.go
2025-08-15 14:23:09 -05:00

34 lines
1.1 KiB
Go

package sushi
// Listen starts the server on the specified address
func (a *App) Listen(addr ...string) error {
address := ":8080"
if len(addr) > 0 && addr[0] != "" {
address = addr[0]
}
return a.Server.ListenAndServe(address)
}
// ListenTLS starts the server with TLS on the specified address
func (a *App) ListenTLS(addr, certFile, keyFile string) error {
return a.Server.ListenAndServeTLS(addr, certFile, keyFile)
}
// Use adds middleware to the app's router
func (a *App) Use(mw ...Middleware) *App {
a.Router.Use(mw...)
return a
}
// Group creates a new route group on the app's router
func (a *App) Group(prefix string) *Group {
return a.Router.Group(prefix)
}
// HTTP method handlers for App
func (a *App) Get(path string, h Handler) error { return a.Router.Get(path, h) }
func (a *App) Post(path string, h Handler) error { return a.Router.Post(path, h) }
func (a *App) Put(path string, h Handler) error { return a.Router.Put(path, h) }
func (a *App) Patch(path string, h Handler) error { return a.Router.Patch(path, h) }
func (a *App) Delete(path string, h Handler) error { return a.Router.Delete(path, h) }