Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: allows slash at the end of each query method #247

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions cmd/fdsn-ws/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package main
import (
"bytes"
"fmt"
"github.com/GeoNet/kit/weft"
"net/http"
"strings"
"time"

"github.com/GeoNet/kit/weft"
)

var mux *http.ServeMux
Expand All @@ -19,21 +20,21 @@ func init() {
mux.HandleFunc("/soh", weft.MakeHandler(soh, weft.UseError))

// fdsn-ws-event
mux.HandleFunc("/fdsnws/event/1", weft.MakeHandler(fdsnEventV1Index, weft.TextError))
mux.HandleFunc("/fdsnws/event/1/", weft.MakeHandler(fdsnEventV1Index, weft.TextError))
mux.HandleFunc("/fdsnws/event/1/query", weft.MakeHandler(fdsnEventV1Handler, fdsnErrorHandler))
mux.HandleFunc("/fdsnws/event/1/version", weft.MakeHandler(fdsnEventVersion, weft.TextError))
mux.HandleFunc("/fdsnws/event/1/catalogs", weft.MakeHandler(fdsnEventCatalogs, weft.TextError))
mux.HandleFunc("/fdsnws/event/1/contributors", weft.MakeHandler(fdsnEventContributors, weft.TextError))
mux.HandleFunc("/fdsnws/event/1/application.wadl", weft.MakeHandler(fdsnEventWadl, weft.TextError))

// fdsn-ws-station
mux.HandleFunc("/fdsnws/station/1", weft.MakeHandler(fdsnStationV1Index, weft.TextError))
mux.HandleFunc("/fdsnws/station/1/", weft.MakeHandler(fdsnStationV1Index, weft.TextError))
mux.HandleFunc("/fdsnws/station/1/query", weft.MakeHandler(fdsnStationV1Handler, fdsnErrorHandler))
mux.HandleFunc("/fdsnws/station/1/version", weft.MakeHandler(fdsnStationVersion, weft.TextError))
mux.HandleFunc("/fdsnws/station/1/application.wadl", weft.MakeHandler(fdsnStationWadl, weft.TextError))

// This service implements the dataselect spec from http://www.fdsn.org/webservices/FDSN-WS-Specifications-1.1.pdf.
mux.HandleFunc("/fdsnws/dataselect/1", weft.MakeHandler(fdsnDataselectV1Index, weft.TextError))
mux.HandleFunc("/fdsnws/dataselect/1/", weft.MakeHandler(fdsnDataselectV1Index, weft.TextError))
mux.HandleFunc("/fdsnws/dataselect/1/query", weft.MakeDirectHandler(fdsnDataselectV1Handler, fdsnErrorHandler))
mux.HandleFunc("/fdsnws/dataselect/1/version", weft.MakeHandler(fdsnDataselectVersion, weft.TextError))
mux.HandleFunc("/fdsnws/dataselect/1/application.wadl", weft.MakeHandler(fdsnDataselectWadl, weft.TextError))
Expand Down
8 changes: 6 additions & 2 deletions cmd/fdsn-ws/routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package main

import (
"fmt"
"github.com/GeoNet/fdsn/internal/holdings"
wt "github.com/GeoNet/kit/weft/wefttest"
"net/http"
"testing"
"time"

"github.com/GeoNet/fdsn/internal/holdings"
wt "github.com/GeoNet/kit/weft/wefttest"
)

// setup() adds event 2015p768477 to the DB.
Expand All @@ -15,6 +16,7 @@ var routes = wt.Requests{

// fdsn-ws-event
{ID: wt.L(), URL: "/fdsnws/event/1", Content: "text/html"},
{ID: wt.L(), URL: "/fdsnws/event/1/", Content: "text/html"},
{ID: wt.L(), URL: "/fdsnws/event/1/query?eventid=2015p768477", Content: "application/xml"},
{ID: wt.L(), URL: "/fdsnws/event/1/version", Content: "text/plain"},
{ID: wt.L(), URL: "/fdsnws/event/1/catalogs", Content: "application/xml"},
Expand All @@ -23,6 +25,7 @@ var routes = wt.Requests{

// fdsn-ws-dataselect
{ID: wt.L(), URL: "/fdsnws/dataselect/1", Content: "text/html"},
{ID: wt.L(), URL: "/fdsnws/dataselect/1/", Content: "text/html"},
{ID: wt.L(), URL: "/fdsnws/dataselect/1/version", Content: "text/plain"},
// an invalid network or no files matching query should give 404 (could also give 204 as per spec)
{ID: wt.L(), URL: "/fdsnws/dataselect/1/query?starttime=2016-01-09T00:00:00&endtime=2016-01-09T23:00:00&network=INVALID_NETWORK&station=CHST&location=01&channel=LOG",
Expand All @@ -37,6 +40,7 @@ var routes = wt.Requests{

// fdsn-ws-station
{ID: wt.L(), URL: "/fdsnws/station/1", Content: "text/html"},
{ID: wt.L(), URL: "/fdsnws/station/1/", Content: "text/html"},
{ID: wt.L(), URL: "/fdsnws/station/1/version", Content: "text/plain"},
{ID: wt.L(), URL: "/fdsnws/station/1/application.wadl", Content: "application/xml"},
{ID: wt.L(), URL: "/fdsnws/station/1/query", Content: "application/xml"},
Expand Down
Loading