return rtr.backend.Logout(ctx, *opts.(*arvados.LogoutOptions))
},
},
+ {
+ arvados.EndpointAuthorizedKeyCreate,
+ func() interface{} { return &arvados.CreateOptions{} },
+ func(ctx context.Context, opts interface{}) (interface{}, error) {
+ return rtr.backend.AuthorizedKeyCreate(ctx, *opts.(*arvados.CreateOptions))
+ },
+ },
+ {
+ arvados.EndpointAuthorizedKeyUpdate,
+ func() interface{} { return &arvados.UpdateOptions{} },
+ func(ctx context.Context, opts interface{}) (interface{}, error) {
+ return rtr.backend.AuthorizedKeyUpdate(ctx, *opts.(*arvados.UpdateOptions))
+ },
+ },
+ {
+ arvados.EndpointAuthorizedKeyGet,
+ func() interface{} { return &arvados.GetOptions{} },
+ func(ctx context.Context, opts interface{}) (interface{}, error) {
+ return rtr.backend.AuthorizedKeyGet(ctx, *opts.(*arvados.GetOptions))
+ },
+ },
+ {
+ arvados.EndpointAuthorizedKeyList,
+ func() interface{} { return &arvados.ListOptions{Limit: -1} },
+ func(ctx context.Context, opts interface{}) (interface{}, error) {
+ return rtr.backend.AuthorizedKeyList(ctx, *opts.(*arvados.ListOptions))
+ },
+ },
+ {
+ arvados.EndpointAuthorizedKeyDelete,
+ func() interface{} { return &arvados.DeleteOptions{} },
+ func(ctx context.Context, opts interface{}) (interface{}, error) {
+ return rtr.backend.AuthorizedKeyDelete(ctx, *opts.(*arvados.DeleteOptions))
+ },
+ },
{
arvados.EndpointCollectionCreate,
func() interface{} { return &arvados.CreateOptions{} },
return rtr.backend.CollectionUntrash(ctx, *opts.(*arvados.UntrashOptions))
},
},
+ {
+ arvados.EndpointComputedPermissionList,
+ func() interface{} { return &arvados.ListOptions{Limit: -1} },
+ func(ctx context.Context, opts interface{}) (interface{}, error) {
+ return rtr.backend.ComputedPermissionList(ctx, *opts.(*arvados.ListOptions))
+ },
+ },
{
arvados.EndpointContainerCreate,
func() interface{} { return &arvados.CreateOptions{} },
return rtr.backend.ContainerCreate(ctx, *opts.(*arvados.CreateOptions))
},
},
+ {
+ arvados.EndpointContainerPriorityUpdate,
+ func() interface{} { return &arvados.UpdateOptions{} },
+ func(ctx context.Context, opts interface{}) (interface{}, error) {
+ return rtr.backend.ContainerPriorityUpdate(ctx, *opts.(*arvados.UpdateOptions))
+ },
+ },
{
arvados.EndpointContainerUpdate,
func() interface{} { return &arvados.UpdateOptions{} },
return rtr.backend.ContainerDelete(ctx, *opts.(*arvados.DeleteOptions))
},
},
- {
- arvados.EndpointContainerRequestCreate,
- func() interface{} { return &arvados.CreateOptions{} },
- func(ctx context.Context, opts interface{}) (interface{}, error) {
- return rtr.backend.ContainerRequestCreate(ctx, *opts.(*arvados.CreateOptions))
- },
- },
- {
- arvados.EndpointContainerRequestUpdate,
- func() interface{} { return &arvados.UpdateOptions{} },
- func(ctx context.Context, opts interface{}) (interface{}, error) {
- return rtr.backend.ContainerRequestUpdate(ctx, *opts.(*arvados.UpdateOptions))
- },
- },
- {
- arvados.EndpointContainerRequestGet,
- func() interface{} { return &arvados.GetOptions{} },
- func(ctx context.Context, opts interface{}) (interface{}, error) {
- return rtr.backend.ContainerRequestGet(ctx, *opts.(*arvados.GetOptions))
- },
- },
- {
- arvados.EndpointContainerRequestList,
- func() interface{} { return &arvados.ListOptions{Limit: -1} },
- func(ctx context.Context, opts interface{}) (interface{}, error) {
- return rtr.backend.ContainerRequestList(ctx, *opts.(*arvados.ListOptions))
- },
- },
- {
- arvados.EndpointContainerRequestDelete,
- func() interface{} { return &arvados.DeleteOptions{} },
- func(ctx context.Context, opts interface{}) (interface{}, error) {
- return rtr.backend.ContainerRequestDelete(ctx, *opts.(*arvados.DeleteOptions))
- },
- },
{
arvados.EndpointContainerLock,
func() interface{} {
return rtr.backend.ContainerSSH(ctx, *opts.(*arvados.ContainerSSHOptions))
},
},
+ {
+ arvados.EndpointContainerSSHCompat,
+ func() interface{} { return &arvados.ContainerSSHOptions{} },
+ func(ctx context.Context, opts interface{}) (interface{}, error) {
+ return rtr.backend.ContainerSSH(ctx, *opts.(*arvados.ContainerSSHOptions))
+ },
+ },
{
// arvados-client built before commit
// bdc29d3129f6d75aa9ce0a24ffb849a272b06f08
return rtr.backend.ContainerGatewayTunnel(ctx, *opts.(*arvados.ContainerGatewayTunnelOptions))
},
},
+ {
+ arvados.EndpointContainerGatewayTunnelCompat,
+ func() interface{} { return &arvados.ContainerGatewayTunnelOptions{} },
+ func(ctx context.Context, opts interface{}) (interface{}, error) {
+ return rtr.backend.ContainerGatewayTunnel(ctx, *opts.(*arvados.ContainerGatewayTunnelOptions))
+ },
+ },
+ {
+ arvados.EndpointContainerRequestCreate,
+ func() interface{} { return &arvados.CreateOptions{} },
+ func(ctx context.Context, opts interface{}) (interface{}, error) {
+ return rtr.backend.ContainerRequestCreate(ctx, *opts.(*arvados.CreateOptions))
+ },
+ },
+ {
+ arvados.EndpointContainerRequestUpdate,
+ func() interface{} { return &arvados.UpdateOptions{} },
+ func(ctx context.Context, opts interface{}) (interface{}, error) {
+ return rtr.backend.ContainerRequestUpdate(ctx, *opts.(*arvados.UpdateOptions))
+ },
+ },
+ {
+ arvados.EndpointContainerRequestGet,
+ func() interface{} { return &arvados.GetOptions{} },
+ func(ctx context.Context, opts interface{}) (interface{}, error) {
+ return rtr.backend.ContainerRequestGet(ctx, *opts.(*arvados.GetOptions))
+ },
+ },
+ {
+ arvados.EndpointContainerRequestList,
+ func() interface{} { return &arvados.ListOptions{Limit: -1} },
+ func(ctx context.Context, opts interface{}) (interface{}, error) {
+ return rtr.backend.ContainerRequestList(ctx, *opts.(*arvados.ListOptions))
+ },
+ },
+ {
+ arvados.EndpointContainerRequestDelete,
+ func() interface{} { return &arvados.DeleteOptions{} },
+ func(ctx context.Context, opts interface{}) (interface{}, error) {
+ return rtr.backend.ContainerRequestDelete(ctx, *opts.(*arvados.DeleteOptions))
+ },
+ },
+ {
+ arvados.EndpointContainerRequestContainerStatus,
+ func() interface{} { return &arvados.GetOptions{} },
+ func(ctx context.Context, opts interface{}) (interface{}, error) {
+ return rtr.backend.ContainerRequestContainerStatus(ctx, *opts.(*arvados.GetOptions))
+ },
+ },
+ {
+ arvados.EndpointContainerRequestLog,
+ func() interface{} { return &arvados.ContainerLogOptions{} },
+ func(ctx context.Context, opts interface{}) (interface{}, error) {
+ return rtr.backend.ContainerRequestLog(ctx, *opts.(*arvados.ContainerLogOptions))
+ },
+ },
{
arvados.EndpointGroupCreate,
func() interface{} { return &arvados.CreateOptions{} },
return rtr.backend.LogDelete(ctx, *opts.(*arvados.DeleteOptions))
},
},
- {
- arvados.EndpointSpecimenCreate,
- func() interface{} { return &arvados.CreateOptions{} },
- func(ctx context.Context, opts interface{}) (interface{}, error) {
- return rtr.backend.SpecimenCreate(ctx, *opts.(*arvados.CreateOptions))
- },
- },
- {
- arvados.EndpointSpecimenUpdate,
- func() interface{} { return &arvados.UpdateOptions{} },
- func(ctx context.Context, opts interface{}) (interface{}, error) {
- return rtr.backend.SpecimenUpdate(ctx, *opts.(*arvados.UpdateOptions))
- },
- },
- {
- arvados.EndpointSpecimenGet,
- func() interface{} { return &arvados.GetOptions{} },
- func(ctx context.Context, opts interface{}) (interface{}, error) {
- return rtr.backend.SpecimenGet(ctx, *opts.(*arvados.GetOptions))
- },
- },
- {
- arvados.EndpointSpecimenList,
- func() interface{} { return &arvados.ListOptions{Limit: -1} },
- func(ctx context.Context, opts interface{}) (interface{}, error) {
- return rtr.backend.SpecimenList(ctx, *opts.(*arvados.ListOptions))
- },
- },
- {
- arvados.EndpointSpecimenDelete,
- func() interface{} { return &arvados.DeleteOptions{} },
- func(ctx context.Context, opts interface{}) (interface{}, error) {
- return rtr.backend.SpecimenDelete(ctx, *opts.(*arvados.DeleteOptions))
- },
- },
{
arvados.EndpointAPIClientAuthorizationCreate,
func() interface{} { return &arvados.CreateOptions{} },
rtr.addRoute(route.endpoint, route.defaultOpts, exec)
}
rtr.mux.NotFoundHandler = http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
+ if req.Method == "OPTIONS" {
+ // For non-webdav endpoints, return an empty
+ // response with the CORS headers we already
+ // added in ServeHTTP.
+ w.WriteHeader(http.StatusOK)
+ return
+ }
httpserver.Errors(w, []string{"API endpoint not found"}, http.StatusNotFound)
})
rtr.mux.MethodNotAllowedHandler = http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
+ if req.Method == "OPTIONS" {
+ // For non-webdav endpoints, return an empty
+ // response with the CORS headers we already
+ // added in ServeHTTP.
+ w.WriteHeader(http.StatusOK)
+ return
+ }
httpserver.Errors(w, []string{"API endpoint not found"}, http.StatusMethodNotAllowed)
})
}
if alt, ok := altMethod[endpoint.Method]; ok {
methods = append(methods, alt)
}
+ if strings.HasSuffix(endpoint.Path, ".*}") {
+ // webdav methods
+ methods = append(methods, "OPTIONS", "PROPFIND")
+ }
rtr.mux.Methods(methods...).Path("/" + endpoint.Path).HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
logger := ctxlog.FromContext(req.Context())
- params, err := rtr.loadRequestParams(req, endpoint.AttrsKey)
+ opts := defaultOpts()
+ params, err := rtr.loadRequestParams(req, endpoint.AttrsKey, opts)
if err != nil {
logger.WithFields(logrus.Fields{
"req": req,
rtr.sendError(w, err)
return
}
- opts := defaultOpts()
- err = rtr.transcode(params, opts)
- if err != nil {
- logger.WithField("params", params).WithError(err).Debugf("error transcoding params to %T", opts)
- rtr.sendError(w, err)
- return
- }
respOpts, err := rtr.responseOptions(opts)
if err != nil {
logger.WithField("opts", opts).WithError(err).Debugf("error getting response options from %T", opts)
}
ctx := auth.NewContext(req.Context(), creds)
ctx = arvados.ContextWithRequestID(ctx, req.Header.Get("X-Request-Id"))
- logger.WithFields(logrus.Fields{
- "apiEndpoint": endpoint,
- "apiOptsType": fmt.Sprintf("%T", opts),
- "apiOpts": opts,
- }).Debug("exec")
+ req = req.WithContext(ctx)
+
// Extract the token UUIDs (or a placeholder for v1 tokens)
var tokenUUIDs []string
for _, t := range creds.Tokens {
tokenUUIDs = append(tokenUUIDs, "v1 token ending in "+end)
}
}
- httpserver.SetResponseLogFields(req.Context(), logrus.Fields{"tokenUUIDs": tokenUUIDs})
+ httpserver.SetResponseLogFields(ctx, logrus.Fields{"tokenUUIDs": tokenUUIDs})
+
+ logger.WithFields(logrus.Fields{
+ "apiEndpoint": endpoint,
+ "apiOptsType": fmt.Sprintf("%T", opts),
+ "apiOpts": opts,
+ }).Debug("exec")
resp, err := exec(ctx, opts)
if err != nil {
logger.WithError(err).Debugf("returning error type %T", err)
case "login", "logout", "auth":
default:
w.Header().Set("Access-Control-Allow-Origin", "*")
- w.Header().Set("Access-Control-Allow-Methods", "GET, HEAD, PUT, POST, PATCH, DELETE")
- w.Header().Set("Access-Control-Allow-Headers", "Authorization, Content-Type, X-Http-Method-Override")
+ w.Header().Set("Access-Control-Allow-Methods", "GET, HEAD, OPTIONS, PROPFIND, PUT, POST, PATCH, DELETE")
+ w.Header().Set("Access-Control-Allow-Headers", "Authorization, Content-Type, Range, X-Http-Method-Override")
+ w.Header().Set("Access-Control-Expose-Headers", "Content-Range")
w.Header().Set("Access-Control-Max-Age", "86486400")
}
- if r.Method == "OPTIONS" {
- return
- }
if r.Body != nil {
// Wrap r.Body in a http.MaxBytesReader(), otherwise
// r.ParseForm() uses a default max request body size