Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func NormalizePort ¶
Types ¶
type Context ¶
type Context interface {
// http objects
GetRequest() *http.Request
GetWriter() http.ResponseWriter
GetPath() string
// get data from request
GetStatusCode() int
GetParam(key string) string
GetQueryParam(key string) string
DecodeJSONBody(v interface{}) error
// set data for response
Status(status int) Context
SetHeader(string, string)
RawResponse(raw []byte)
JSONResponse(data interface{})
StringResponse(data string)
// cookies
SetCookie(cookie *http.Cookie)
GetCookie(name string) (*http.Cookie, error)
// logger
Logger() *logrus.Logger
// contains filtered or unexported methods
}
type HandlerFunc ¶
type HandlerFunc func(Context)
type Middleware ¶
type Middleware func(HandlerFunc) HandlerFunc
This implementation of middleware will enable middleware chaining
type RouteGroup ¶ added in v0.5.5
type RouteGroup interface {
Use(middleware Middleware)
Get(path string, handler HandlerFunc)
Post(path string, handler HandlerFunc)
Put(path string, handler HandlerFunc)
Delete(path string, handler HandlerFunc)
Patch(path string, handler HandlerFunc)
Handle(method string, path string, handler HandlerFunc)
RouteGroup(path string) RouteGroup
}
type Router ¶ added in v0.5.6
type Router interface {
ServeFiles(string, http.FileSystem)
ServeHTTP(http.ResponseWriter, *http.Request)
HandlerFunc(method string, path string, handler http.HandlerFunc)
ParamsFromContext(context.Context) Params
Router() *httprouter.Router
}
type Server ¶
type Server interface {
// Start and Stop
Start()
Shutdown() error
// Middleware
Use(Middleware)
// RouteGroup
RouteGroup(path string) RouteGroup
// HTTP methods
Get(path string, handler HandlerFunc)
Post(path string, handler HandlerFunc)
Put(path string, handler HandlerFunc)
Delete(path string, handler HandlerFunc)
Patch(path string, handler HandlerFunc)
// Handle arbitrary HTTP methods
Handle(method string, path string, handler HandlerFunc)
// Other Server methods
Static(string, string)
// Helpers
Test(method string, path string, body io.Reader, params ...TestParams) (httptest.ResponseRecorder, error)
}
func New ¶ added in v0.5.3
func New(userconfig ...*ServerConfig) Server
New creates a new server instance Configurations can be passed as a parameter and It's optional If no configurations are passed, default values are used
type ServerConfig ¶
Click to show internal directories.
Click to hide internal directories.