rob05c commented on issue #2124: Add TO Go GET deliveryservices routes
URL: 
https://github.com/apache/incubator-trafficcontrol/pull/2124#issuecomment-380616330
 
 
   @DylanVolz What do you think of this versioning scheme?
   
   The highlights are: 
   
   Structs are versioned via anonymous members:
   ```
   type DeliveryServiceNullableV13 struct {
        DeliveryServiceNullableV12
        DeepCachingType   *DeepCachingType `json:"deepCachingType" 
db:"deep_caching_type"`
   ```
   
   There's a `GetRefType` for each different version:
   ```
   func GetRefTypeV12() *TODeliveryServiceV12 {
        return &refTypeV12
   }
   
   {1.3, http.MethodGet, `deliveryservices/?(\.json)?$`, 
api.ReadHandler(deliveryservice.GetRefTypeV13()...
   ```
   (This still isn't necessary for routes that don't change, e.g. `divisions` 
can still only have `{1.2, http.MethodGet, "divisions/?(\\.json)?$", 
api.ReadHandler(division.GetRefTypeV12()...` [which implicitly serves `1.3`])
   
   CRUD can re-use database functions which return the latest version:
   ```
   func (ds *TODeliveryServiceV12) Read(db *sqlx.DB, params map[string]string, 
user auth.CurrentUser) ([]interface{}, []error, tc.ApiErrorType) {
   ...
   returnable = append(returnable, ds.DeliveryServiceNullableV12)
   ```
   
   And functions on each API alias that don't change can be reused:
   ```
   func (ds *TODeliveryServiceV13) GetType() string {
        v12 := TODeliveryServiceV12(ds.DeliveryServiceNullableV12)
        return v12.GetType()
   }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to