Documentation ¶
Index ¶
- Variables
- func Decode(r *http.Request, v interface{}) *errors.AppError
- func HealthHandeler(w http.ResponseWriter, r *http.Request)
- func IndexHandeler(w http.ResponseWriter, r *http.Request)
- func InitService(name, version string)
- func JustDecode(r *http.Request, v interface{}) error
- type Handler
- type ServiceInfo
Constants ¶
This section is empty.
Variables ¶
var FormDecoder *schema.Decoder
FormDecoder gorrila schema decoder is used to decode form data & query params into structs. And it validates the data against the struct types. supported types: - bool, - float32, float64, - int, int8, int16, int32, int64, - string, []string, - uint, uint8, uint16, uint32, uint64, - struct and we can write custom decoders for custom types. example time.Time, uuid.UUID, etc..
var RequestIDHeader = "X-Request-Id"
RequestIDHeader is the name of the HTTP Header which contains the request id. Exported so that it can be changed by developers
var (
ServiceName = ""
)
ServiceName holds the service which connected to
Functions ¶
func Decode ¶
Decode - decodes the request body and extends the validator interface with the Validate() method
EX:
type User struct { Email string `json:"email"` Name string `json:"name"` } func (c *Component) Validate() *errors.AppError { if c.Email == "" { return errors.IsRequiredErr("email") } return nil }
func HealthHandeler ¶
func HealthHandeler(w http.ResponseWriter, r *http.Request)
HealthHandeler return basic service info
func IndexHandeler ¶
func IndexHandeler(w http.ResponseWriter, r *http.Request)
IndexHandeler common index handler for all the service
func JustDecode ¶
JustDecode just decodes the request body