Documentation ¶
Index ¶
- func Response(w http.ResponseWriter, r *http.Request, statusCode int, body []byte)
- func ResponseJSON(w http.ResponseWriter, r *http.Request, statusCode int, body interface{}) error
- func ResponseString(w http.ResponseWriter, r *http.Request, statusCode int, body interface{})
- type Cors
- type Opts
- type Server
- func (s *Server) DELETE(path string, handler http.HandlerFunc)
- func (s *Server) GET(path string, handler http.HandlerFunc)
- func (s *Server) HEAD(path string, handler http.HandlerFunc)
- func (s *Server) ListenError() <-chan error
- func (s *Server) OPTIONS(path string, handler http.HandlerFunc)
- func (s *Server) PATCH(path string, handler http.HandlerFunc)
- func (s *Server) POST(path string, handler http.HandlerFunc)
- func (s *Server) PUT(path string, handler http.HandlerFunc)
- func (s *Server) Run()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Response ¶
Response response by writing the body to http.ResponseWriter. Call at the end line of your handler.
func ResponseJSON ¶
ResponseJSON response by writing body with json encoder into http.ResponseWriter. Body must be either struct or map[string]interface{}. Otherwise would result in incorrect parsing at client side. If you have []byte as response body, then use Response function instead. Call at the end line of your handler.
func ResponseString ¶
func ResponseString(w http.ResponseWriter, r *http.Request, statusCode int, body interface{})
ResponseString response in form of string whatever passed into body param. Call at the end line of your handler.
Types ¶
type Cors ¶
type Cors struct { AllowedOrigins []string AllowedMethods []string AllowedHeaders []string ExposedHeaders []string MaxAge int AllowCredentials bool IsDebug bool }
Cors corst options
type Opts ¶
type Opts struct { Port uint16 // EnableLogger enable logging for incoming requests EnableLogger bool // IdleTimeout keep-alive timeout while waiting for the next request coming. If empty then no timeout. IdleTimeout time.Duration // Cors optional, can be nil, if nil then default will be set. Cors *Cors }
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) ListenError ¶
Click to show internal directories.
Click to hide internal directories.