currently am working on an API Rest in Golang. I have the process to CRUD all the tables. Now someone is asking me to develop an endpoint to search in one of that tables based on the parameters send in the URL. Let's say that this is my struct for that table:

type Media struct {
    ID                         uint       
    Key                   string     
    RecordKey           string     
    RecordID            string     
    SystemMediaKey      string          
    MediaObjectID       string   
    ChangedByID         string   
    ChangedByKey        string   
    MediaCategory              string   
    MimeType                   string   
    ShortDescription           string   
    LongDescription            string   
    EntryTimestamp             time.Time
    ModificationTimestamp      time.Time  
    DeletedAtTimestamp         *time.Time 
    MediaModificationTimestamp time.Time
    MediaURL                   string   
    MediaHTML                  string   
    Order                      int      
    Group                      string   
    Width                      int      
    Height                     int      
    ImageSize                  string   
    ResourceName               string  
    ClassName                  string 
    Permission                 *string
    MediaStatus                string
}

Now, he can send me all or some of that fields in the URL, the I need to assign that values to my struct to be able to search in the database based on the data assigned to the object.

I am using Gorm to handle everything with the database, gorilla/schema to assign the values on the POST requests and the Julien Schmidt Router. Now,my questions are:

  1. What should I configure in the route to accept dynamic parameters?
  2. How can I assign the values that comes in the URL to the a type Media object? Thank you!