Mercurial > gemma
view pkg/controllers/bnimports.go @ 1556:6869eb94ead2
Don't error if an action is not defined if bound.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 11 Dec 2018 20:47:11 +0100 |
parents | 165f31b71042 |
children | 49c04bb64e0a |
line wrap: on
line source
// This is Free Software under GNU Affero General Public License v >= 3.0 // without warranty, see README.md and license for details. // // SPDX-License-Identifier: AGPL-3.0-or-later // License-Filename: LICENSES/AGPL-3.0.txt // // Copyright (C) 2018 by via donau // – Österreichische Wasserstraßen-Gesellschaft mbH // Software engineering by Intevation GmbH // // Author(s): // * Sascha L. Teichmann <sascha.teichmann@intevation.de> package controllers import ( "database/sql" "log" "net/http" "gemma.intevation.de/gemma/pkg/auth" "gemma.intevation.de/gemma/pkg/common" "gemma.intevation.de/gemma/pkg/imports" "gemma.intevation.de/gemma/pkg/models" ) func importBottleneck( input interface{}, req *http.Request, conn *sql.Conn, ) (jr JSONResult, err error) { bi := input.(*models.BottleneckImport) bn := &imports.Bottleneck{ URL: bi.URL, Insecure: bi.Insecure, } var serialized string serialized, err = common.ToJSONString(bn) if err != nil { return } session, _ := auth.GetSession(req) jobID, err := imports.AddJob(imports.BNJobKind, session.User, serialized) if err != nil { return } log.Printf("info: added import #%d to queue\n", jobID) result := struct { ID int64 `json:"id"` }{ ID: jobID, } jr = JSONResult{ Code: http.StatusCreated, Result: &result, } return }