1
// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
2
// Use of this source code is governed by a MIT style
3
// license that can be found in the LICENSE file.
8
"github.com/gin-gonic/gin/binding"
12
// DEPRECATED, use Bind() instead.
13
// Like ParseBody() but this method also writes a 400 error if the json is not valid.
14
func (c *Context) EnsureBody(item interface{}) bool {
18
// DEPRECATED use bindings directly
19
// Parses the body content as a JSON input. It decodes the json payload into the struct specified as a pointer.
20
func (c *Context) ParseBody(item interface{}) error {
21
return binding.JSON.Bind(c.Request, item)
24
// DEPRECATED use gin.Static() instead
25
// ServeFiles serves files from the given file system root.
26
// The path must end with "/*filepath", files are then served from the local
27
// path /defined/root/dir/*filepath.
28
// For example if root is "/etc" and *filepath is "passwd", the local file
29
// "/etc/passwd" would be served.
30
// Internally a http.FileServer is used, therefore http.NotFound is used instead
31
// of the Router's NotFound handler.
32
// To use the operating system's file system implementation,
34
// router.ServeFiles("/src/*filepath", http.Dir("/var/www"))
35
func (engine *Engine) ServeFiles(path string, root http.FileSystem) {
36
engine.router.ServeFiles(path, root)
39
// DEPRECATED use gin.LoadHTMLGlob() or gin.LoadHTMLFiles() instead
40
func (engine *Engine) LoadHTMLTemplates(pattern string) {
41
engine.LoadHTMLGlob(pattern)
44
// DEPRECATED. Use NoRoute() instead
45
func (engine *Engine) NotFound404(handlers ...HandlerFunc) {
46
engine.NoRoute(handlers...)