add more methods
This commit is contained in:
		@@ -26,6 +26,10 @@ export default class Router {
 | 
			
		||||
    const methods = {
 | 
			
		||||
      get:  this.get.bind(this),
 | 
			
		||||
      post: this.post.bind(this),
 | 
			
		||||
      head: this.head.bind(this),
 | 
			
		||||
      put: this.put.bind(this),
 | 
			
		||||
      delete: this.delete.bind(this),
 | 
			
		||||
      patch: this.patch.bind(this),
 | 
			
		||||
    };
 | 
			
		||||
    const target = {
 | 
			
		||||
      path: new RegExp(path),
 | 
			
		||||
@@ -69,6 +73,38 @@ export default class Router {
 | 
			
		||||
    return this;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  head(path, ...args) {
 | 
			
		||||
    if(args.length === 1)
 | 
			
		||||
      this.registerRoute(path, args[0], "head");
 | 
			
		||||
    else
 | 
			
		||||
      this.registerRoute(path, args[1], "head", args[0]);
 | 
			
		||||
    return this;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  put(path, ...args) {
 | 
			
		||||
    if(args.length === 1)
 | 
			
		||||
      this.registerRoute(path, args[0], "put");
 | 
			
		||||
    else
 | 
			
		||||
      this.registerRoute(path, args[1], "put", args[0]);
 | 
			
		||||
    return this;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  delete(path, ...args) {
 | 
			
		||||
    if(args.length === 1)
 | 
			
		||||
      this.registerRoute(path, args[0], "delete");
 | 
			
		||||
    else
 | 
			
		||||
      this.registerRoute(path, args[1], "delete", args[0]);
 | 
			
		||||
    return this;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  patch(path, ...args) {
 | 
			
		||||
    if(args.length === 1)
 | 
			
		||||
      this.registerRoute(path, args[0], "patch");
 | 
			
		||||
    else
 | 
			
		||||
      this.registerRoute(path, args[1], "patch", args[0]);
 | 
			
		||||
    return this;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  registerRoute(path, cb, method, middleware) {
 | 
			
		||||
    if(!this.routes.has(path))
 | 
			
		||||
      this.routes.set(path, {});
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user