Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add http method #1102

Closed
ddatsh opened this Issue Oct 10, 2018 · 4 comments

Comments

Projects
None yet
4 participants
@ddatsh
Copy link

ddatsh commented Oct 10, 2018

postman , http method include

COPY/LINK/UNLINK/PURGE/LOCK/UNLOCK/PROPFIND/VIEW
package main
import (
	"github.com/kataras/iris"
)
func main(){
	app := iris.New()
	app.Any("/", handler)
	app.Run(iris.Addr(":8080"))
}
func handler(ctx iris.Context){
	ctx.Writef("method: %s and path: %s", ctx.Method(), ctx.Path())
}
curl -X LINK http://127.0.0.1:8080/
Not Found

@ddatsh ddatsh referenced this issue Oct 10, 2018

Closed

add http method #1103

@syssam

This comment has been minimized.

Copy link

syssam commented Oct 11, 2018

These are not standard HTTP METHODS.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods

@Dexus

This comment has been minimized.

Copy link

Dexus commented Oct 13, 2018

It's not standard HTTP METHODS but webdav and this may usefull if you build apps that need it. So I would like to vote for an option to enable webdav methodes and other methods that are non standard - but need for special cases.

Regards, Josef

@kataras

This comment has been minimized.

Copy link
Owner

kataras commented Oct 15, 2018

Maybe a better feature request before a PR is to initialize support for modifying the HTTP methods that Iris will allow you to register a handler? They live at: https://github.com/kataras/iris/blob/master/core/router/api_builder.go#L25


For the next release, version 11 which lives on its own branch at v11. We will not touch the current v10 anymore for new features.

@kataras kataras added this to the v11 milestone Oct 15, 2018

kataras added a commit that referenced this issue Oct 16, 2018

@kataras

This comment has been minimized.

Copy link
Owner

kataras commented Oct 16, 2018

@syssam when version 11 will be released you can do it by:

package main

import (
	"github.com/kataras/iris"
         // import that package as well:
        routing "github.com/kataras/iris/core/router"
)

func init() {
       // or inside your main func, just register them before your `app.Any` call:
       myCustomMethods := []string{"COPY",
		"LINK",
		"UNLINK",
		"PURGE",
		"LOCK",
		"UNLOCK",
		"PROPFIND",
		"VIEW",
        }

        // available for all iris instances.
        routing.AllMethods = append(routing.AllMethods, myCustomMethods...)
}

func main() {
	app := iris.New()
	app.Any("/mypath", func(ctx iris.Context) { /*[...]*/})
	app.Run(iris.Addr(":8080"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.