Skip to content

Conversation

@buma
Copy link
Contributor

@buma buma commented Dec 11, 2016

I added Last-Modified field to headers. Value is last modified time of each mbtiles file.

Code probably isn't great since this is my first Go code.

Copy link
Collaborator

@brendan-ward brendan-ward left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@buma first off, thank you for making a foray into Go to help with this project! A few minor fixes, and I think this will be a nice addition.

Note: semicolons at the end of lines are unnecessary, and are automatically stripped by gofmt (please make sure to run that before committing Go code...)

I'd like to see modTime excluded from the tilejson response body; it isn't part of the specification and I didn't find a common convention for it. Add it to the list of excluded keys around line 407.

main.go Outdated
id = strings.Split(id, ".")[0]

//Saves last modified mbtiles time for setting Last-Modified header
file, err := os.Open(filename)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 155 - 167 could be done more simply like:

fileStat, err := os.Stat(filename)
if err != nil {
    log.Errorf("could not read file stats for mbtiles file: %s\n", filename)
    continue
}

then line 190 could be

metadata["modTime"] = fileStat.ModTime().Round(time.Second)

@buma
Copy link
Contributor Author

buma commented Dec 16, 2016

I fixed, what you requested. Code is much nicer now.

@brendan-ward brendan-ward merged commit f446948 into consbio:master Dec 17, 2016
@brendan-ward
Copy link
Collaborator

Thanks @buma 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants