Skip to content

add RegisterServerFile & support EnabledAutoHEAD\EnabledAutoOPTIONS in ServerFile - #176

Merged
devfeel merged 1 commit into
masterfrom
develop
Jan 3, 2019
Merged

add RegisterServerFile & support EnabledAutoHEAD\EnabledAutoOPTIONS in ServerFile #176
devfeel merged 1 commit into
masterfrom
develop

Conversation

@devfeel

@devfeel devfeel commented Jan 3, 2019

Copy link
Copy Markdown
Owner
  • New Feature: HttpServer & Router add RegisterServerFile use to register ServerFile router with routeMethod method on http.FileServer
  • Update: ServerFile add support for EnabledAutoHEAD\EnabledAutoOPTIONS
  • Detail:
    • when use ServerFile, default routeMethod is GET
    • you can use RegisterServerFile specify other HttpMethod, like "POST"
  • Example:
	server.RegisterServerFile(dotweb.RouteMethod_POST, "/dst/*", "/home/www/")
  • How To:
    • how to add support "HEAD" method for all requests in your httpserver?
    func main() {
    	app := dotweb.Classic("/home/logs/wwwroot/")
    
      // if use this, all router will auto add "HEAD" method support
      // default is false
      app.HttpServer.SetEnabledAutoHEAD(true)
    
    	app.HttpServer.GET("/index", func(ctx dotweb.Context) error{
    		return ctx.WriteString("welcome to my first web!")
    	})
    
    	err := app.StartServer(80)
        fmt.Println("dotweb.StartServer error => ", err)
    }
  • 2019-01-03 10:00

* New Feature: HttpServer & Router add RegisterServerFile use to register ServerFile router with routeMethod method on http.FileServer
* Update: ServerFile add support for EnabledAutoHEAD\EnabledAutoOPTIONS
* Detail:
    - when use ServerFile, default routeMethod is GET
    - you can use RegisterServerFile specify other HttpMethod, like "POST"
* Example:
``` golang
	server.RegisterServerFile(dotweb.RouteMethod_POST, "/dst/*", "/home/www/")
```
* How To:
  - how to add support "HEAD" method for all requests in your httpserver?
  ~~~go
  func main() {
  	app := dotweb.Classic("/home/logs/wwwroot/")

    // if use this, all router will auto add "HEAD" method support
    // default is false
    app.HttpServer.SetEnabledAutoHEAD(true)

  	app.HttpServer.GET("/index", func(ctx dotweb.Context) error{
  		return ctx.WriteString("welcome to my first web!")
  	})

  	err := app.StartServer(80)
      fmt.Println("dotweb.StartServer error => ", err)
  }
  ~~~
* 2019-01-03 10:00
@devfeel
devfeel merged commit 9c9057a into master Jan 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant