github.com/bitcubate/cryptojournal@v1.2.5-0.20171102134152-f578b3d788ab/src/lib/resource/urls.go (about)

     1  package resource
     2  
     3  import (
     4  	"fmt"
     5  )
     6  
     7  // IndexURL returns the index url for this model - /table
     8  func (r *Base) IndexURL() string {
     9  	return fmt.Sprintf("/%s", r.TableName)
    10  }
    11  
    12  // CreateURL returns the create url for this model /table/create
    13  func (r *Base) CreateURL() string {
    14  	return fmt.Sprintf("/%s/create", r.TableName)
    15  }
    16  
    17  // UpdateURL returns the update url for this model /table/id/update
    18  func (r *Base) UpdateURL() string {
    19  	return fmt.Sprintf("/%s/%d/update", r.TableName, r.ID)
    20  }
    21  
    22  // DestroyURL returns the destroy url for this model /table/id/destroy
    23  func (r *Base) DestroyURL() string {
    24  	return fmt.Sprintf("/%s/%d/destroy", r.TableName, r.ID)
    25  }
    26  
    27  // ShowURL returns the show url for this model /table/id
    28  func (r *Base) ShowURL() string {
    29  	return fmt.Sprintf("/%s/%d", r.TableName, r.ID)
    30  }
    31  
    32  // PublicURL returns the canonical url for showing this resource
    33  // usually this will differ in using the name as a slug
    34  func (r *Base) PublicURL() string {
    35  	return fmt.Sprintf("/%s/%d", r.TableName, r.ID)
    36  }